我有网络服务,它正在返回 XML 数据。但在数据中,我在它的开头收到了 Null 字段。实际数据也可用,但后跟 Null 字段。我正在使用 ksoap2 访问 Android 中的网络服务。 SoapObject 变量具有完整数据,但也有那些空字段,这在使用此服务时会产生一些问题。在这里你可以看到,一开始它什么都没有,但后来它有以标签“标题”开头的数据
04-12 10:55:09.405: D/ENVELOPE(1394): GetGuestEventsListingForServiceResponse{GetGuestEventsListingForServiceResult=anyType{schema=anyType{element=anyType{complexType=anyType{choice=anyType{element=anyType{complexType=anyType{sequence=anyType{element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; }; }; }; }; }; }; }; diffgram=anyType{NewDataSet=anyType{Table=anyType{Title=THE CLUSTER DAY-1, JUNKOVATION; Description=anyType{}; EventDate=Apr 12, 2013; EventTime=5:00 PM; Venue=BLOCK 13-306; CreatedBy=16689; CreatedOn=2013-04-11T09:52:07.163+05:30; EventFor=All; Type=Internal; IsActive=true; };
最佳答案
我不明白问题出在哪里。如果将结果字符串格式化为 xml,您将获得:
<GetGuestEventsListingForServiceResponse>
<GetGuestEventsListingForServiceResult>
<schema>
<element>
<complexType>
<choice>
<element>
<complexType>
<sequence>
<element/>
<element/>
<element/>
<element/>
<element/>
<element/>
<element/>
<element/>
<element/>
<element/>
</sequence>
</complexType>
</element>
</choice>
</complexType>
</element>
</schema>
<diffgram>
<NewDataSet>
<Table>
<Title>THE CLUSTER DAY-1, JUNKOVATION</Title>
<Description/>
<EventDate>Apr 12, 2013</EventDate>
<EventTime>5:00 PM</EventTime>
<Venue>BLOCK 13-306</Venue>
<CreatedBy>16689</CreatedBy>
<CreatedOn>2013-04-11T09:52:07.163+05:30</CreatedOn>
<EventFor>All</EventFor>
<Type>Internal</Type>
<IsActive>true</IsActive>
</Table>
</NewDataSet>
</diffgram>
</GetGuestEventsListingForServiceResult>
</GetGuestEventsListingForServiceResponse>
如果你的意思是为什么有那些空元素,你必须检查服务器端的网络服务。如果您在服务器端与“.NET”Web 服务交互,请尝试将绑定(bind)设置为 BasicBinding
关于android - .net web 服务在数据开头返回 NULL 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15970094/