How to create a java client using AXis 1.4 to use the WCF service using wsHttpBinding

I created a java client to use the WCF service using the 1.4 axis. If I use basicHttpBinding, than everything works fine, but if I use wsHttpBinding, I get the following error: -

Did not understand "MustUnderstand" header(s):{http://www.w3.org/2005/08/addressing}Action
AxisFault
 faultCode: {http://www.w3.org/2003/05/soap-envelope}MustUnderstand
 faultSubcode: 
 faultString: Did not understand "MustUnderstand" header(s):{http://www.w3.org/2005/08/addressing}Action
 faultActor: 
 faultNode: 
 faultDetail: 
    {http://xml.apache.org/axis/}stackTrace:
    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:96)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at org.tempuri.WSHttpBinding_IService1Stub.getData(WSHttpBinding_IService1Stub.java:171)
    at Mytes.main(Mytes.java:14)

    {http://xml.apache.org/axis/}hostname:2207A-H7-SITA

Did not understand "MustUnderstand" header(s):{http://www.w3.org/2005/08/addressing}Action
    at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:96)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
    at org.apache.axis.client.Call.invoke(Call.java:2767)
    at org.apache.axis.client.Call.invoke(Call.java:2443)
    at org.apache.axis.client.Call.invoke(Call.java:2366)
    at org.apache.axis.client.Call.invoke(Call.java:1812)
    at org.tempuri.WSHttpBinding_IService1Stub.getData(WSHttpBinding_IService1Stub.java:171)
    at Mytes.main(Mytes.java:14)

Pls tell me how I can fix this error. Thank.

+3
source share
2 answers

When you use Axis to create a proxy for the WCF service, it generates a stub that automatically sets the header MustUnderstandforhttp://www.w3.org/2005/08/addressing

MustUnderstand false. . , , .

//maybe someother service stub,i show you a case
    CommentWcfServiceLocator locator =new CommentWcfServiceLocator();
    WSHttpBinding_ICommentServiceStub stub;
    try {       
    //get a stub and set service url
    stub = (WSHttpBinding_ICommentServiceStub)   locator.getWSHttpBinding_ICommentService(new         java.net.URL("http://www.google.com/CommentWcfService.svc"));

    // the key is here , importantest!!! follow this
    // set action, action path,you can find in your java code
    SOAPHeaderElement action = new SOAPHeaderElement(new QName("wsa:Action"),     "http://tempuri.org/ICommentService/GetCommentSummaryByHotelId");
    SOAPHeaderElement to = new SOAPHeaderElement(new QName("wsa:To"),
    stub._getProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY));
        action.setActor(null);
        action.setNamespaceURI("http://www.w3.org/2005/08/addressing");
        to.setActor(null);
        to.setNamespaceURI("http://www.w3.org/2005/08/addressing");
         // set header
                stub.setHeader(action);
        stub.setHeader(to);
                // must set this property
        stub._setProperty(Call.CHECK_MUST_UNDERSTAND, Boolean.FALSE);
            stub.getCommentSummaryByHotelId("","02201158", 0);
    } 
catch(Exception EX){}

MustUnderstand veru .

+3
-2

Source: https://habr.com/ru/post/1755736/


All Articles