【发布时间】:2018-11-02 02:03:17
【问题描述】:
我正在使用 Android Studio 和 ksoap2(版本 3.6.2)连接到一个肥皂网络服务,我得到一个 SoapObject 作为回报,但 不是 符合预期。我在为 xml 请求中的嵌套属性创建代码时遇到问题。即使向请求添加属性,Web 服务也始终发送相同的响应(.xml 请求在 SoapUI 上运行良好,并且 Web 服务发送正确的响应)。
这是我需要从 Android 发送的 .xml:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org /soap/envelope/" xmlns:glob="http://abc.def">
<soapenv:Header/>
<soapenv:Body>
<glob:MaterialByElements>
<MaterialSelectionByElements>
<SelectionByID>
<Code>I</Code>
<TypeCode>1</TypeCode>
<ID>IM-640</ID>
</SelectionByID>
</MaterialSelectionByElements>
</glob:MaterialByElements>
</soapenv:Body>
</soapenv:Envelope>
这是Android中的代码:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapObject SelectionByID = new SoapObject(NAMESPACE, "SelectionByID");
SelectionByID .addProperty("Code", "I");
SelectionByID .addProperty("TypeCode", "1");
SelectionByID .addProperty("ID", "IM-640-1045");
SoapObject MaterialSelectionByElements = new SoapObject(NAMESPACE,"MaterialSelectionByElements");
MaterialSelectionByElements.addSoapObject(SelectionByID);
request.addSoapObject(MaterialSelectionByElements);
但是网络服务总是发送响应,就好像我应该在请求中发送它一样:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org /soap/envelope/" xmlns:glob="http://abc.def">
<soapenv:Header/>
<soapenv:Body>
<glob:MaterialByElements>
<MaterialSelectionByElements>
</MaterialSelectionByElements>
</glob:MaterialByElements>
</soapenv:Body>
</soapenv:Envelope>
请,任何帮助将不胜感激。提前致谢!
注意:我已经检查了请求中的 Namespace、MethodName 和 URL。
请帮忙。
【问题讨论】:
标签: android-studio soap xml-parsing android-ksoap2 ksoap