如何将命名空间添加到soap Envelope中去,并在soap body中引用。 我用WSDL2jiava工具生成代码,发送的soap消息如下:
<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Header> <ns1:AuthenticationToken xmlns:ns1="http://service.subscription.hua.com"> <ns1:SessionID>21000</ns1:SessionID> </ns1:AuthenticationToken> </soapenv:Header> <soapenv:Body> <ns5:KeyValue xmlns:ns5="http://api.common.hua.com"> <ns5:key>price</ns5:key> <ns5:value>100.00</ns5:value> </ns5:KeyValue> </soapenv:Body> </soapenv:Envelope>如何将上面的代码写成如下格式:
<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://service.subscription.hua.com" xmlns:ns5="http://api.common.hua.com"> <soapenv:Header> <ns1:AuthenticationToken> <ns1:SessionID>21000</ns1:SessionID> </ns1:AuthenticationToken> </soapenv:Header> <soapenv:Body> <ns5:KeyValue> <ns5:key>price</ns5:key> <ns5:value>100.00</ns5:value> </ns5:KeyValue> </soapenv:Body> </soapenv:Envelope>答: 没办法,自己研究axis-1.4源代码,终于搞定了。 修改了axis的源代码。 axis全称Apache Extensible Interaction System, 即阿帕奇可扩展交互系统。Axis本质上就是一个SOAP引擎,提供创建服务器端、客户端和网关SOAP操作的基本框架。