var code = "d4653cd9-b58b-4e0f-9eed-76028da0a7f7"
默认生成的报文
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header/>
<soap:Body>
<ns2:xx_xx_xx_xx>
预期报文
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:yyyy="http://www.xxx.xx.xx">
<soapenv:Header/>
<soapenv:Body>
<ns2:xx_xx_xx_xx>
报文生成方式为
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setAddress(url); // for SOAP 1.2 factory.setBindingId(SoapBindingConstants.SOAP11_BINDING_ID); factory.setServiceClass(clazz);
T webService = (T) factory.create(); Client proxy = ClientProxy.getClient(webService); HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
HashMap<String, String> hmap = new HashMap<String, String>(); hmap.put("soapenv", "http://schemas.xmlsoap.org/soap/envelope/"); hmap.put("xxx", "http://xx.xx.xxx.xxx");
if (CollUtil.isNotEmpty(hmap)) { proxy.getRequestContext().put("soap.env.ns.map", hmap); proxy.getRequestContext().put("disable.outputstream.optimization", "true"); }
后记
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xxxx="http://xxxx.xxxx.xxxx/xxx/xxx">
<soapenv:Body>
<xxxx:xxxx_xxx_xx_xxx>
需要在接口中添加 targetNamespace="http://xxxx.xxxx.xxxx/xxx/xxx" 这个地址要和 hmap.put("xxxx", "http://xxxx.xxxx.xxxx/xxx/xxx"); 中写的一样
@WebService(name = "xxxx_xxx_xx_xxx", targetNamespace="http://xxxx.xxxx.xxxx/xxx/xxx") @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) public interface XxxYxxxxYxxxSend { @WebMethod(operationName = "xxxx_xxx_xx_xxx", action = "http://sap.com/xi/WebService/soap1.1") @WebResult(name = "xxxx_xxx_xx_xxx", partName = "xxxx_xxx_xx_xxx") XxxYxxxxYxxxSendResponse yyyyyy( @WebParam(partName = "xxxx_xxx_xx_xxx", name = "xxxx_xxx_xx_xxx") XxxYxxxxYxxxSendRequest xxxYxxxxYxxxSendRequest );