我使用Netbeans生成了一个JAX-WS Web服务客户端,所有工作都正常,除非我将Axis2库添加到项目中,从soap标头中删除了UsernameToken,并且soap消息看起来略有不同。我对Java Web服务很陌生,所以我真的很想了解发生了什么以及如何解决这个问题。我需要拥有Axis2库的原因是我将一个客户端添加到一个拥有许多Axis2客户端的大型项目中。
存在Axis2库时生成的SOAP:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" />
</soapenv:Header>
<soapenv:Body>
<ns2:AddOrUpdate xmlns:ns2="http://tempuri.org/" xmlns="http://schemas.datacontract.org/2004/07/Service.DataTransferObjects" xmlns:ns4="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:ns3="http://schemas.datacontract.org/2004/07/Service.ServiceUtils">
<ns2:employee />
</ns2:AddOrUpdate>
</soapenv:Body>
没有Axis2库的生成SOAP:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>username</wsse:Username>
<wsse:Password>password1</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</S:Header>
<S:Body>
<AddOrUpdate xmlns="http://tempuri.org/" xmlns:ns2="http://schemas.datacontract.org/2004/07/Service.DataTransferObjects" xmlns:ns3="http://schemas.datacontract.org/2004/07/Service.ServiceUtils" xmlns:ns4="http://schemas.microsoft.com/2003/10/Serialization/">
<employee/>
</AddOrUpdate>
</S:Body>