我正在使用我的Android应用程序调用Web服务,并且没有错误,但我仍然坚持下一点:
以下是我的回复:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns4:conResponse returnStatus="SRV_STATUS_SUCCESS" xmlns:ns5="https://myserver.fr/Server/GameOps/" xmlns:ns4="https://myserver.fr/Server/MainOps/" xmlns:ns3="https://myserver.fr/Server/CoreServices/" xmlns:ns2="https://myserver.fr/Server/Models/"/>
</soap:Body>
</soap:Envelope>
和此代码
SoapObject result = (SoapObject) envelope.bodyIn;
int count = result.getPropertyCount();
int count2 = result.getAttributeCount();
返回count = 0和count2 = 0
我需要获取returnStatus属性,我该怎么做?
修改1 我正在准备这样的请求:
String NAMESPACE = "https://myserver.fr/Server/MainOps/";
String METHODNAME = "conRequest";
String URL = "myserver.com/myproject/MainOpsSOAP";
String SOAPACTION = NAMESPACE + "connect";
SoapObject main = new SoapObject(NAMESPACE, METHODNAME);
main.addProperty("id", "id1");
main.addProperty("name", "name1");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(main);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAPACTION, envelope);
return envelope;
编辑2 我试着修改我的complexType,这里我注意到了
当我的回答定义如下:
<xsd:complexType name="WSResponse">
<xsd:attribute name="returnStatus" type="coreservices:ReturnStatusEnum" use="required" />
</xsd:complexType>
我的envelope.bodyIn不包含任何属性或属性,
但是当我通过这个修改这个定义时:
<xsd:complexType name="WSResponse">
<xsd:sequence>
<xsd:element name="returnStatus" type="coreservices:ReturnStatusEnum" />
</xsd:sequence>
</xsd:complexType>
我的envelope.bodyIn包含“returnStatus”属性
答案 0 :(得分:0)
当你获得信封时,你必须这样做
SoapObject result = (SoapObject) envelope.bodyIn;
SoapObject resultCollection = result.getProperty("getMethodCollectionResult");
int count = resultCollection.getPropertyCount();
int count2 = resultCollection.getAttributeCount();