期望SOAP12HeaderImpl成为父类,得到类org.apache.axiom.om.impl.llom.OMElementImpl Java Client

时间:2015-10-28 07:45:19

标签: java web-services axis2 wso2esb wsdl2java

我使用Axis2为使用WSO2-ESB的给定WSDL生成了Stub。因此,当我调用WS

时,我将向标头添加以下参数
  1. 简单身份验证(用户名,密码)
  2. WS-Addressing(true) - WS-A
  3. WS-Reliable Messaging(true) - WS-RM
  4. 要将WS-RM添加到标题我已使用ApacheSandesha2

    我的代码段是,

     HttpTransportProperties.Authenticator  basicAuthentication = new HttpTransportProperties.Authenticator();
    
    basicAuthentication.setUsername("xxxxxxxx");
    basicAuthentication.setPassword("xxxxxxxx");
    
    System.out.println("Basic Authentication have generated");
    
    BankingSaviPaySoapStub bankingSaviPaySoapStub = new BankingSaviPaySoapStub();
    
    /**Setting Web Service Authentication Properties to the Stub*/
    bankingSaviPaySoapStub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
    bankingSaviPaySoapStub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, basicAuthentication);
    
    /**Setting WSA Properties to the Stub*/
    bankingSaviPaySoapStub._getServiceClient().getOptions().setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
      AddressingConstants.Submission.WSA_NAMESPACE);
    bankingSaviPaySoapStub._getServiceClient().getOptions().setProperty(AddressingConstants.INCLUDE_OPTIONAL_HEADERS,
      Boolean.TRUE); 
    
    
    /**Setting WS-RM Properties to the Stub*/
    bankingSaviPaySoapStub._getServiceClient().engageModule("addressing");
    
    System.out.println("engaged addressing module.");
    bankingSaviPaySoapStub._getServiceClient().engageModule("sandesha2");
    
    System.out.println("engaged sandesha2 module.");
    bankingSaviPaySoapStub._getServiceClient().getOptions().setProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID, SandeshaUtil.getUUID());
    bankingSaviPaySoapStub._getServiceClient().getOptions().setProperty(SandeshaClientConstants.RM_SPEC_VERSION, Sandesha2Constants.SPEC_VERSIONS.v1_1);
    bankingSaviPaySoapStub._getServiceClient().getOptions().setProperty(SandeshaClientConstants.SEQUENCE_KEY, SandeshaUtil.getUUID());
    bankingSaviPaySoapStub._getServiceClient().getOptions().setTransportInProtocol(Constants.TRANSPORT_HTTP);
    bankingSaviPaySoapStub._getServiceClient().getOptions().setProperty(SandeshaClientConstants.AcksTo, AddressingConstants.Final.WSA_ANONYMOUS_URL);
    
    /*Set SOAP Version.*/
    bankingSaviPaySoapStub._getServiceClient().getOptions().setSoapVersionURI(org.apache.axis2.namespace.Constants.URI_SOAP12_ENV);
    

    当我使用上面的代码调用Web服务方法时。我得到以下错误。

        org.apache.axis2.AxisFault: Sandesha2 got an exception when processing an out message: org.apache.axiom.soap.SOAPProcessingException: Expecting SOAP12HeaderImpl as parent, got class org.apache.axiom.om.impl.llom.OMElementImpl at org.apache.sandesha2.handlers.SandeshaOutHandler.invoke(SandeshaOutHandler.java:166)
            at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:340)
            at org.apache.axis2.engine.Phase.invoke(Phase.java:313)
            at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:262)
            at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:427)
            at org.apache.axis2.description.OutInAxisOperationClient.sendAsync(OutInAxisOperation.java:312)
            at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
            at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
            at com.fg.ws.BankingSaviPaySoapStub.startpayAnyone(BankingSaviPayanyone1_0SoapStub.java:413)
            at com.fg.ws.app.App.<init>(App.java:148)
            at com.fg.ws.app.App.main(App.java:156)
    Caused by: org.apache.axiom.soap.SOAPProcessingException: Expecting SOAP12HeaderImpl as parent, got class org.apache.axiom.om.impl.llom.OMElementImpl
    

    我打印了ServiceClient选项。所有选项都绑定如下。

    {Sandesha2AcksTo=http://www.w3.org/2005/08/addressing/anonymous, WSAddressingVersion=http://schemas.xmlsoap.org/ws/2004/08/addressing, includeOptionalHeaders=true, _NTLM_DIGEST_BASIC_AUTHENTICATION_=org.apache.axis2.transport.http.HttpTransportProperties$Authenticator@f539f96, __CHUNKED__=false, Sandesha2OfferedSequenceId=urn:uuid:286E463BCCB1EC15301446014283931, Sandesha2RMSpecVersion=Spec_2007_02, Sandesha2SequenceKey=urn:uuid:286E463BCCB1EC15301446014283932}
    

0 个答案:

没有答案