Hi Erwin,

I just happen to go through your original mail once more and I realized that what you want is to get the whole soap envelope along with the tag <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";> as in :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
           <soapenv:Body>
              <ns:additionResponse xmlns:ns="http://add.math.com/xsd";>
                 <ns:return>10</ns:return>
              </ns:additionResponse>
           </soapenv:Body>
        </soapenv:Envelope>

Sorry that I misunderstood what you said. :-(

The method you have to call to get the entire response is *response.getBuilder().getDocumentElement()getDocumentElement()*

********************************************************************************

       ServiceClient client = new ServiceClient();
       Options opts = new Options();
opts.setTo(new EndpointReference("http://localhost:8001/axis2/services/Adding";));
       opts.setAction("urn:addition");
       client.setOptions(opts);
       OMElement res = client.sendReceive(createPayLoad());
System.out.println(res.getBuilder().getDocumentElement()); //Prints the entire soap response

********************************************************************************

Then you will get the response as follows.

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
       <soapenv:Body>
           <ns:additionResponse xmlns:ns="http://add.math.com/xsd";>
               <ns:return>10</ns:return>
           </ns:additionResponse>
       </soapenv:Body>
</soapenv:Envelope>


I hope this is what you want. :-)

Thanks,
Evanthika.

Evanthika Amarasiri wrote:
Hi Erwin,

You can get the entire soap envelope by calling the getParent() method. I tried the same and it worked for me. I will give you the steps how I did it so that you can check it against what you have done.

My service is a simple one which adds up two integers. The soap envelope which is sent as the request is as below.

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
      <soapenv:Body>
         <ns1:adding xmlns:ns1="http://add.math.com/xsd";>
            <ns1:x>4</ns1:x>
            <ns1:y>6</ns1:y>
         </ns1:adding>
      </soapenv:Body>
   </soapenv:Envelope>


Therefore I create my payload as follows. I'm giving you the Service Client which I have written for my service. See if you can get anything out of it. :-)

/*The createPayLoad method will generate the payload*/

     public static OMElement createPayLoad() {
            OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://add.math.com/xsd";, "ns1"); //Replace this with your own namespace
            OMElement adding = fac.createOMElement("adding", omNs);
            OMElement x = fac.createOMElement("x", omNs);
            OMElement y = fac.createOMElement("y", omNs);
x.setText("4");
            y.setText("6");
adding.addChild(x);
            adding.addChild(y);
            return adding;
        }


    public static void main(String[] args) throws Exception {
        ServiceClient client = new ServiceClient();
        Options opts = new Options();
opts.setTo(new EndpointReference("http://localhost:8080/axis2/services/Adding";)); //Replace this with your service EPR
        opts.setAction("urn:addition");  //Put your own action here
        client.setOptions(opts);
OMElement res = client.sendReceive(createPayLoad()); //The above method which creates the payload
        System.out.println(res.getParent());
    }


Once I run the client, I get the response as :

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
    <ns:additionResponse xmlns:ns="http://add.math.com/xsd";>
        <ns:return>10</ns:return>
    </ns:additionResponse>
</soapenv:Body>

I hope this will help you to solve your problem. :-)

Thanks,
Evanthika


Erwin Reinhoud wrote:
It is probably the latter then since i try to go to the parent but that was null. Thanks.

    -----Oorspronkelijk bericht-----
    *Van:* Ryan Nelsestuen [mailto:[EMAIL PROTECTED]
    *Verzonden:* donderdag 15 maart 2007 15:39
    *Aan:* [email protected]
    *Onderwerp:* RE: axis2 1.1.1 serializing more than returned
    OMElement from ServiceClient.sendReceive

    You might be able to call "getParent()" until it returns null --
    the top element should be the soap envelope.  Otherwise I think
    the soap envelope is abstracted away by design, and you'd have to
    plug in your own flow handlers or write your own module.

    ------------------------------------------------------------------------

    *From:* Erwin Reinhoud [mailto:[EMAIL PROTECTED]
    *Sent:* Thursday, March 15, 2007 8:30 AM
    *To:* [email protected]
    *Subject:* axis2 1.1.1 serializing more than returned OMElement
    from ServiceClient.sendReceive

    Hello,

    I would like to print more than content of body element in the
    retruned OMElement from ServiceClient.sendReceive(arg). I cant
    seem to find a way of doing this. Do i needt to create the call
    differently in order to be be able to print the whole soap
    response  envelope?

    Thanks in advance.

    Kind regards,

    Erwin



Reply via email to