axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: R: Newbie info on messaging
Date Wed, 17 Nov 2004 14:43:21 GMT
The method, in your service, has two parameters. The second parameter is a 
SOAPEnvelope, in which to put your response. You can get the body of the 
element with:
SOAPBody body = resp.getBody();
You can add a body element (this will be the root of your response message 
XML) to the body using:
SOAPBodyElement bodyElement = body.addBodyElement(new 
PrefixedQName(yourNamespace, yourElementName, yourPrefix));
You'd also need to add namespace declarations to bodyElement, for the 
namespace of the element itself and for any other namespaces you might use 
in the response. Then you can add child element to the bodyElement, using 
addChildElement(). You can add child elements to those child elements, and 
so on.
To add a header, use something like:
header = new SOAPHeaderElement( yourHeaderNamespace, 
resp.addHeader( header );

Obviously, you can add children to the header, in the same way as for the 
body element.

Hope this helps.


I already saw the MessageService, but unfortunately it is quite far from 
being useful.
I want to put some application xml info into the header section of the 
SOAPEnvelope and some other application xml info into the body section of 
the SOAPEnvelope.
I made a Message and I put some xml attachments into it, and it's ok.
I cannot understand how to build a SOAPHeader and a SOAPBody to the 
response envelope.
any clue?

Da: [] 
Inviato: mercoledì 17 novembre 2004 12.20
Oggetto: Re: Newbie info on messaging


I don't know about attachments, but you don't need to use the 
MessageContext to add headers and body elements to the response. The 
second parameter has the SOAP envelope that will be passed back to the 
client and it already has a SOAP body. So you only need to add body 
element to the SOAP body and add headers to the response SOAP envelope 
(though headers are usually added in an Axis handler, not in the web 
service itself). 

Axis comes with sample services, so you may be able to find something in 


Hi all
I am quite new on axis. I have to implement a request/response service 
my service contains method(SOAPEnvelope req, SOAPEnvelope resp) ).
I managed to build the client, send a SOAPEnvelope correctly, receive the
envelope on the server.
I wasn't able to create a response message using setHeader, setBody and
I understand I have to use the MessageContext.

Where can I find examples about this kind of issues?

View raw message