我正在尝试使用JAX-WS Client生成这样的请求:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:alin="http://www.alinma.com" xmlns="http://www.alinma.com">
<soapenv:Header/>
<soapenv:Body>
<alin:CustDtlsInqRq>
<alin:MsgRqHdr>
<RqUID>BPM11957T201508101626333904816</RqUID>
<SCId>BPMP</SCId>
<FuncId>24000000</FuncId>
<RqMode>0</RqMode>
<CustLangPref>En</CustLangPref>
<CustId>
<CIF>6060</CIF>
</CustId>
<AgentId>OprtSupportReviewer</AgentId>
</alin:MsgRqHdr>
<Body>
<CIF>6060</CIF>
</Body>
</alin:CustDtlsInqRq>
</soapenv:Body>
但请求是这样生成的:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://www.alinma.com">
<S:Header/>
<S:Body>
<ns2:CustDtlsInqRq xmlns:ns2="http://www.alinma.com">
<MsgRqHdr xmlns="">
<RqUID>OLPM201508261333149660000020</RqUID>
<SCId>BPMP</SCId>
<FuncId>24000000</FuncId>
<CustLangPref>En</CustLangPref>
<CustId>
<CIF>6060</CIF>
</CustId>
</MsgRqHdr>
<Body xmlns="">
<CIF>6060</CIF>
</Body>
</ns2:CustDtlsInqRq>
</S:Body>
添加的标记xmlns=""
会在服务器端出现问题
这是我的处理程序的代码,它使用SOAP Envelop围绕请求
if (outboundProperty.booleanValue()) {
try {
SOAPMessage soapMessage = context.getMessage();
SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
soapEnvelope.addNamespaceDeclaration("", "http://www.alinma.com");
// Grab the header of the SOAP envelop
SOAPHeader soapHeader = soapEnvelope.getHeader();
// Attach a new header if there is none...
if (soapHeader == null) {
soapHeader = soapEnvelope.addHeader();
}
soapMessage.saveChanges();
soapMessage.writeTo(System.out); //TODO: remove this line (just for debugging)
} catch (Exception e) {
logger.error("Error Creating SOAP message", e);
}
}
如何调整空xmlns
代码?