JAX-WS为iBM websphere,IBM Web服务客户端添加寻址

时间:2015-11-21 17:04:42

标签: java web-services soap wsdl

我在websphere上运行代码并使用soap 2.12-2.2?和RAD工具生成IBM JAX-WS Web服务客户端代码。我可以连接到有问题的服务器,但Web服务需要寻址。如果我使用http客户端代码和soap ui,我可以让这个请求工作,我看到特定的SOAP动作寻址头。但是我找不到为jax-ws代码添加这个的方法。我提到了websphere ibm,因为我想知道它是否是该代码内部的错误。在封面下,jk-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);

1 个答案:

答案 0 :(得分:1)

如前所述here,要做的就是添加AddressingFeature创建端口的位置(示例来自Oracle文档):

HelloWorld port = service.getHelloWorldPort(
    new AddressingFeature(true, true));