我正在websphere上运行代码,并使用soap 2.12-2.2?。以及RAD工具来生成IBM JAX-WS web服务客户端代码。我可以连接到有问题的服务器,但web服务需要寻址。如果我使用http客户端代码和soap ui,我可以让这个请求工作,并且我可以看到特定的soap操作寻址头。但是我找不到为jax-ws代码添加此内容的方法。我提到websphereibm是因为我想知道它是否是该代码内部的bug。从表面上看,这个库是jax-ws的org.apache.axis2。这是我尝试过的所有代码。
预期请求:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="http://schemas.schedulenow.com/paramedclients/services" xmlns:data="http://schemas.schedulenow.com/paramedclients/data" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Action soap:mustUnderstand="1">http://sion</wsa:Action><wsa:To soap:mustUnderstand="1">...</wsa:To></soap:Header>
<soap:Body>
<ser:Initialize>
当我获取原始字符串并访问服务器时,它包含一个有效的请求。当我使用jax-ws-ibm-cod.e时,缺少"wsa:Action"。
WSDL包含以下内容:
但由于某种原因,客户端就是不添加所需的头。我尝试了以下方法。
SSLSocketFactory sslFactory = GenerateSocketAndTrustManager.createSSLFactory();
_desc.getDispatch().getRequestContext().put("com.ibm.ws.wsaddressingAndDependentsDisabled", false);
_desc.getDispatch().getRequestContext().put("com.ibm.ws.wsaddressingAndDependentsDisabled", false);
_desc.getDispatch().getRequestContext().put("com.ibm.ws.wsaddressing.disabled", false);
_desc.getDispatch().getRequestContext().put("com.ibm.ws.wsaddressing.wsdl.UsingAddressing", true);
@Addressing(enabled=true, required=true)
@WebServiceClient(name = "ScheduleService", targetNamespace = "http://tempuri.org/", wsdlLocation = "WEB-INF/wsdl/ScheduleService_1.wsdl")
AddressingFeature feat = new AddressingFeature(true, false);
_service.getWSHttpBindingScheduleService(feat);
如前所述,方法是在创建端口的地方添加AddressingFeature
(示例取自Oracle文档):
HelloWorld port = service.getHelloWorldPort(
new AddressingFeature(true, true));