我正在调用带有少量参数的请求对象的Web服务方法。我发送的Xml是:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"></Action>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<findRequest xmlns="http://servicesweow2.com">
<parameter>
<name>IsClosed</name>
<value>true</value>
</parameter>
<parameter>
<name>IsDistinct</name>
<value>false</value>
</parameter>
</findRequest>
</s:Body>
</s:Envelope>
&#13;
但是在示例中xml看起来像:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ser="http://servicesweow2.com">
<soapenv:Header/>
<soapenv:Body>
<ser:findRequest>
<ser:parameter>
<ser:name>IsClosed</ser:name>
<ser:value>true</ser:value>
</ser:parameter>
<ser:parameter>
<ser:name>IsDistinct</ser:name>
<ser:value>false</ser:value>
</ser:parameter>
</ser:findRequest>
</soapenv:Body>
</soapenv:Envelope>
&#13;
我在代码中所做的就是调用方法并传递新对象。有没有办法改变XML命名空间&lt; s:到&lt; soapenv:并添加&lt; ser:参数前? 使用的代码:
MyService src = new MyService();
findRequest req = new findRequest();
var response = src.findTasks(req);