我有一个 android 客户端,它使用 ksoap 与用 c# asp.net 编写的 wsdl web 服务进行通信。我在匹配 Web 服务和客户端之间的参数类型时遇到问题。 Web 服务器期望这种请求(自动生成):
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetDetails xmlns="http://host.org/">
<event_id>int</event_id>
</GetDetails>
</soap:Body>
</soap:Envelope>
客户端使用 ksoap 发送请求,它们看起来像这样:
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
<n0:GetDetails id="o0" c:root="1" xmlns:n0="http://tempuri.org">
<event_id i:type="d:int">1</event_id>
</n0:GetDetails>
</v:Body>
</v:Envelope>
出于某种原因,当请求被手动组装为看起来像第一个选项时,WS 将以下客户端的请求解析为 0(我猜是因为附加的类型属性 - i:type="d:int"),它工作正常。 我怎样才能使 Web 服务正确读取 ksoap 格式,或者我怎样才能将它的预期格式更改为看起来像 ksoap 请求。 (网络服务 soap 协议(protocol)是自动生成的)。
请您参考如下方法:
这个解决方案有两个部分: 1.关于删除属性类型,我在这里找到了答案: using addMapping without the "i:type=" attribute in ksoap2 for android 我需要设置:
envelope.implicitTypes = true;
- namespace 必须以退格键结尾,我错过了。
