You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Marcello Marangio <m....@tno.it> on 2004/11/17 11:33:27 UTC

Newbie info on messaging

Hi all
I am quite new on axis. I have to implement a request/response service (i.e.
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
addAttachment.
I understand I have to use the MessageContext.

Where can I find examples about this kind of issues?
Cheers
Marcello



Re: How can I get the full path of the destination endpoint of a soap message in the handler

Posted by Dacheng <dc...@comp.leeds.ac.uk>.
it works, thanks a lot,Tony.

dacheng
----- Original Message ----- 
From: <to...@gsk.com>
To: <ax...@ws.apache.org>
Sent: Monday, November 22, 2004 9:39 AM
Subject: Re: How can I get the full path of the destination endpoint of a
soap message in the handler


> You can get the original HTTP servlet request with:
>
> ( HttpServletRequest )msgContext.getProperty(
> HTTPConstants.MC_HTTP_SERVLETREQUEST )
> And, from this, you can get at all the information you need about the
> request, including getRequestURL(), which returns the full client request
> URL.
> Tony
>
>
>
> Dacheng <dc...@comp.leeds.ac.uk>
> 21-Nov-2004 01:17
>
>
>
>
>
> Hi, everyone:
>
> I am developing a handler and try to use this handler to print out the
> destinations of the SOAP messages. Current I only can use
> MessageContext.getTargetService() to get the name of the service. Could
> anyone do me a favor to tell me how to get the full path (such as
> http://129.234.4.11/testWebservice) of a Web service in a handler?
>
> Thank you in advance!!!
>
> Dacheng
>
>
>
>


Re: How can I get the full path of the destination endpoint of a soap message in the handler

Posted by to...@gsk.com.
You can get the original HTTP servlet request with:

( HttpServletRequest )msgContext.getProperty( 
HTTPConstants.MC_HTTP_SERVLETREQUEST )
And, from this, you can get at all the information you need about the 
request, including getRequestURL(), which returns the full client request 
URL.
Tony



Dacheng <dc...@comp.leeds.ac.uk> 
21-Nov-2004 01:17





Hi, everyone:

I am developing a handler and try to use this handler to print out the
destinations of the SOAP messages. Current I only can use
MessageContext.getTargetService() to get the name of the service. Could
anyone do me a favor to tell me how to get the full path (such as
http://129.234.4.11/testWebservice) of a Web service in a handler?

Thank you in advance!!!

Dacheng




How can I get the full path of the destination endpoint of a soap message in the handler

Posted by Dacheng <dc...@comp.leeds.ac.uk>.
Hi, everyone:

I am developing a handler and try to use this handler to print out the
destinations of the SOAP messages. Current I only can use
MessageContext.getTargetService() to get the name of the service. Could
anyone do me a favor to tell me how to get the full path (such as
http://129.234.4.11/testWebservice) of a Web service in a handler?

Thank you in advance!!!

Dacheng


Re: R: R: Newbie info on messaging

Posted by to...@gsk.com.
Check out the methods on the classes I've mentioned, and the other related 
classes. I haven't done a lot of this kind of work and haven't got time, 
at the moment, to delve further, but if you check out the methods and look 
at some of the examples that come with Axis, you should be able to work 
this out.

Tony



So I have to scroll the xml (or DOM) structure to add each BodyElement one 
by one?
Is it the same for haders?
Isn't there a way to add an xml InputStream to the SOAP body?
thanx
M

Da: tony.q.weddle@gsk.com [mailto:tony.q.weddle@gsk.com] 
Inviato: mercoledì 17 novembre 2004 15.43
A: axis-user@ws.apache.org
Oggetto: Re: R: Newbie info on messaging

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, 
yourHeaderElementName); 
resp.addHeader( header ); 

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

Hope this helps. 

Tony 


Hi 
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? 
Cheers 
Marcello 
 

Da: tony.q.weddle@gsk.com [mailto:tony.q.weddle@gsk.com] 
Inviato: mercoledì 17 novembre 2004 12.20
A: axis-user@ws.apache.org
Oggetto: Re: Newbie info on messaging


Marcello, 

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 
there. 

Tony



Hi all
I am quite new on axis. I have to implement a request/response service 
(i.e.
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
addAttachment.
I understand I have to use the MessageContext.

Where can I find examples about this kind of issues?
Cheers
Marcello





R: R: Newbie info on messaging

Posted by Marcello Marangio <m....@tno.it>.
 
So I have to scroll the xml (or DOM) structure to add each BodyElement one
by one?
Is it the same for haders?
Isn't there a way to add an xml InputStream to the SOAP body?
thanx
M


  _____  

Da: tony.q.weddle@gsk.com [mailto:tony.q.weddle@gsk.com] 
Inviato: mercoledì 17 novembre 2004 15.43
A: axis-user@ws.apache.org
Oggetto: Re: R: Newbie info on messaging



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, yourHeaderElementName);

resp.addHeader( header ); 

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

Hope this helps. 

Tony 


Hi 
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? 
Cheers 
Marcello 
  



  _____  

Da: tony.q.weddle@gsk.com [mailto:tony.q.weddle@gsk.com] 
Inviato: mercoledì 17 novembre 2004 12.20
A: axis-user@ws.apache.org
Oggetto: Re: Newbie info on messaging


Marcello, 

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
there. 

Tony



Hi all
I am quite new on axis. I have to implement a request/response service (i.e.
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
addAttachment.
I understand I have to use the MessageContext.

Where can I find examples about this kind of issues?
Cheers
Marcello







Re: R: Newbie info on messaging

Posted by to...@gsk.com.
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, 
yourHeaderElementName);
resp.addHeader( header );

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

Hope this helps.

Tony


Hi
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?
Cheers
Marcello
 

Da: tony.q.weddle@gsk.com [mailto:tony.q.weddle@gsk.com] 
Inviato: mercoledì 17 novembre 2004 12.20
A: axis-user@ws.apache.org
Oggetto: Re: Newbie info on messaging


Marcello, 

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 
there. 

Tony



Hi all
I am quite new on axis. I have to implement a request/response service 
(i.e.
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
addAttachment.
I understand I have to use the MessageContext.

Where can I find examples about this kind of issues?
Cheers
Marcello





R: Newbie info on messaging

Posted by Marcello Marangio <m....@tno.it>.
Hi
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?
Cheers
Marcello
 


  _____  

Da: tony.q.weddle@gsk.com [mailto:tony.q.weddle@gsk.com] 
Inviato: mercoledì 17 novembre 2004 12.20
A: axis-user@ws.apache.org
Oggetto: Re: Newbie info on messaging



Marcello, 

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
there. 

Tony



Hi all
I am quite new on axis. I have to implement a request/response service (i.e.
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
addAttachment.
I understand I have to use the MessageContext.

Where can I find examples about this kind of issues?
Cheers
Marcello







Re: Newbie info on messaging

Posted by to...@gsk.com.
Marcello,

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 
there.

Tony



Hi all
I am quite new on axis. I have to implement a request/response service 
(i.e.
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
addAttachment.
I understand I have to use the MessageContext.

Where can I find examples about this kind of issues?
Cheers
Marcello