Get SOAP headers from Axis2 stub

Discussions

XML & Web services: Get SOAP headers from Axis2 stub

  1. Get SOAP headers from Axis2 stub (7 messages)

    I have a client Stub generated from a WSDL. WSDL defines several operations. When I call one of those operations using the stub, the actual SOAP payload includes a SOAP header. From the client Stub, how can I view the contents of the incoming SOAP headers? The WSDL unfortunately does not document the returning SOAP headers, only the SOAP Body. Is there a way to read the SOAP Envelope from a Stub? I've been able to modify the generated stub code and do it that way using msgContext = _operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE); msgContext.getEnvelope(); ... But is that the right way of doing it? Isn't there a handler that I can use to trace through the returning SOAP response invoked by the client? Thanks much!
  2. Hi Patrick, Say your post, could you please help me in let me know how to retrieve the Soap envelope, and hence the soap header of the incoming request at my server end. I am using Axis 2. Thanks, Shiva
  3. Solution needed for me[ Go to top ]

    Hi, Can you please let me know how did u solve this issue. I need to access the soap headers sent from the client in the service. Can u tell me the api or approach to get hold of the soap headers/message context in the web service. I am using Axis2 with tomcat, and eclipse plugins for generating stub/client. Thanks, KSK
  4. Hi, I'm the same question. I used Axis2 plugin in eclipse to generate STUB from wsdl on Jboss. My web services is a oneway service that return void value. But in the client I have to obtain a parameter present in HTTP HEADER response generated from skeleton. I wrote this code for client to call web service AddPersonOneway: //****************************************** // get stub autogenerated from plugin ecplise HandlerPersonProxyServerWSStub stub = new HandlerPersonProxyServerWSStub(); // get parameter handler of web services AddPersonOneway paramAddPerson = new AddPersonOneway(); // set parameter paramAddPerson.setPerson(person); // call web service stub.addPersonOneway(paramAddPerson); //******************************************
  5. Greetings, => to add SOAP headers to WS using stub generated by Axis2 MyGeneratedStub clientStub = new MyGeneratedStub(...); ServiceClient serviceClient = clientStub._getServiceClient(); QName qname = new QName("namespaceURI","localPart","prefix"); serviceClient.addStringHeader(qname, "value"); => to add HTTP header to the WS request using stub generated by Axis2 You need well defined MessageContext (not null) so you could modify the stub code (for instance MyGeneratedStub.java) using addHttpHeader method this.addHttpHeader(_messageContext, "Your header name", "Your header value");
  6. This depends on the databinding you used to generate the code.

    From Client side when using JAXB you do the following:
      MessageContext message = stub._getServiceClient().getLastOperationContext().getMessageContext(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE);  
    SOAPHeader  soapHeader = message.getEnvelope().getHeader();
  7. using code i am unable print the soap headers[ Go to top ]

    org.apache.axis2.context.MessageContext message = stub._getServiceClient().getLastOperationContext().getMessageContext(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE);  
    System.out.println(message.getEnvelope().getBody().getNamespace().getNamespaceURI());
    System.out.println(message.getWSAAction())


    SOAPHeader  soapHeader = message.getEnvelope().getHeader();
     System.out.println(soapHeader);*/
      please help me

    Thanks Ramesh

  8. using code i am unable print the soap headers[ Go to top ]


      TestStub stub = new TestStub();
     
     AddTwoNumbers re=new AddTwoNumbers();
     
     re.setFirstNumber(1);
     re.setSecondNumber(5);
     AddTwoNumbersResponse res=stub.addTwoNumbers(re);
     System.out.println(res.get_return());

    org.apache.axis2.context.MessageContext message = stub._getServiceClient().getLastOperationContext().getMessageContext(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE);  
    System.out.println(message.getEnvelope().getBody().getNamespace().getNamespaceURI());
    System.out.println(message.getWSAAction());

    SOAPEnvelope envelope = message.getEnvelope();
    System.out.println(envelope.getSOAPBodyFirstElementLocalName());
    System.out.println(envelope.getChildren().toString());

     

     

     

    how to print soap headers in that class please help me