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 Alecsandru Chirosca <al...@comtec.ro> on 2005/04/25 15:48:38 UTC
SOAP Body and Header response
Hi,
Please help me wth this one....
I tryed and googled a lot in the last 10 days without any result. I need
to return a SOAP response that is containing informations in both SOAP
header and SOAP body. I have the beans that correctly serialize to the
elements in header and boby but I cannot put them togheter.
Please point me in the right direction here...
BR,
Alecs
Re: SOAP Body and Header response
Posted by Alecsandru Chirosca <al...@comtec.ro>.
Thanks a lot!
Thanks for your response.
BR,
Alecs
On Tue, 2005-04-26 at 10:11 +0300, Alecsandru Chirosca wrote:
> Thanks for your answer!
>
> You are refering to a Context. What is this context?
>
> I have build the --server-side of the service WSDL and I don't have any
> reference to a contaxt in the impl class.
> Please help.
>
>
> Sorry, but I'm now to AXIS.
>
> Br,
> Alecs
>
> On Mon, 2005-04-25 at 10:22 -0400, mmalinos@aessuccess.org wrote:
> > Alecs,
> >
> > If I understand you're question correctly, the following code should help.
> >
> > Service Side:
> >
> > String someResponse = "some response";
> >
> > // Get Response Envelope
> > SOAPEnvelope responseEnv = ctx.getResponseMessage().getSOAPEnvelope();
> >
> > // Create Bean
> > ResponseHeader responseHeader = new ResponseHeader();
> > responseHeader.setValue1("Value1");
> > responseHeader.setValue2("Value2");
> > ...
> >
> > // Create SOAP Header Element
> > SOAPHeaderElement responseHeaderElement = new
> > SOAPHeaderElement("http://www.somedomainname.com", "ResponseHeader",
> > responseHeader);
> > or
> > SOAPHeaderElement responseHeaderElement = new
> > SOAPHeaderElement("http://www.somedomainname.com", "ResponseHeader");
> > responseHeaderElement.setObjectValue(responseHeader);
> >
> >
> > // Add header to response envelope
> > responseEnv.addHeader(responseRoutingElement);
> >
> > return response;
> >
> >
> > Client Side is similar:
> >
> > // After the invoke
> >
> > //Get the response envelope
> > SOAPEnvelope returnEnv =
> > call.getMessageContext().getResponseMessage().getSOAPEnvelope();
> >
> > //Get the header with the same names that you put it into the SOAP with.
> > SOAPHeaderElement responseHeaderElement =
> > returnEnv.getHeaderByName("http://www.somedomainname.com","ResponseHeader");
> >
> > //Grab the object out of the header element.
> > responseHeader = null;
> > if(responseHeaderElement != null)
> > {
> > // Get the bean from the SOAP...
> > responseHeader = (ResponseHeader)
> > responseHeaderElement.getObjectValue();
> > // Do whatever you need to do.
> > }
> > else
> > {
> > // Trouble
> > System.out.println("headerElement = null");
> > }
> >
> >
> > You need to make sure you have your bean serialization/deserialization
> > set-up correctly on both ends.
> > The response will be in the return value from the invoke...
> >
> > Mark A. Malinoski
> > AES/PHEAA
> > Technical Coordinator/Web Development
> > 717-720-2413
> > mmalinos@aessuccess.org
> >
> >
> >
> >
> >
> > Alecsandru
> > Chirosca
> > <alecsandru.chiro To
> > sca@comtec.ro> axis-user@ws.apache.org
> > cc
> > 04/25/2005 09:48
> > AM Subject
> > SOAP Body and Header response
> >
> > Please respond to
> > axis-user@ws.apac
> > he.org
> >
> >
> >
> >
> >
> >
> > Hi,
> >
> > Please help me wth this one....
> >
> > I tryed and googled a lot in the last 10 days without any result. I need
> > to return a SOAP response that is containing informations in both SOAP
> > header and SOAP body. I have the beans that correctly serialize to the
> > elements in header and boby but I cannot put them togheter.
> >
> > Please point me in the right direction here...
> >
> >
> > BR,
> > Alecs
> >
> >
> >
>
Re: SOAP Body and Header response
Posted by Alecsandru Chirosca <al...@comtec.ro>.
Thanks for your answer!
You are refering to a Context. What is this context?
I have build the --server-side of the service WSDL and I don't have any
reference to a contaxt in the impl class.
Please help.
Sorry, but I'm now to AXIS.
Br,
Alecs
On Mon, 2005-04-25 at 10:22 -0400, mmalinos@aessuccess.org wrote:
> Alecs,
>
> If I understand you're question correctly, the following code should help.
>
> Service Side:
>
> String someResponse = "some response";
>
> // Get Response Envelope
> SOAPEnvelope responseEnv = ctx.getResponseMessage().getSOAPEnvelope();
>
> // Create Bean
> ResponseHeader responseHeader = new ResponseHeader();
> responseHeader.setValue1("Value1");
> responseHeader.setValue2("Value2");
> ...
>
> // Create SOAP Header Element
> SOAPHeaderElement responseHeaderElement = new
> SOAPHeaderElement("http://www.somedomainname.com", "ResponseHeader",
> responseHeader);
> or
> SOAPHeaderElement responseHeaderElement = new
> SOAPHeaderElement("http://www.somedomainname.com", "ResponseHeader");
> responseHeaderElement.setObjectValue(responseHeader);
>
>
> // Add header to response envelope
> responseEnv.addHeader(responseRoutingElement);
>
> return response;
>
>
> Client Side is similar:
>
> // After the invoke
>
> //Get the response envelope
> SOAPEnvelope returnEnv =
> call.getMessageContext().getResponseMessage().getSOAPEnvelope();
>
> //Get the header with the same names that you put it into the SOAP with.
> SOAPHeaderElement responseHeaderElement =
> returnEnv.getHeaderByName("http://www.somedomainname.com","ResponseHeader");
>
> //Grab the object out of the header element.
> responseHeader = null;
> if(responseHeaderElement != null)
> {
> // Get the bean from the SOAP...
> responseHeader = (ResponseHeader)
> responseHeaderElement.getObjectValue();
> // Do whatever you need to do.
> }
> else
> {
> // Trouble
> System.out.println("headerElement = null");
> }
>
>
> You need to make sure you have your bean serialization/deserialization
> set-up correctly on both ends.
> The response will be in the return value from the invoke...
>
> Mark A. Malinoski
> AES/PHEAA
> Technical Coordinator/Web Development
> 717-720-2413
> mmalinos@aessuccess.org
>
>
>
>
>
> Alecsandru
> Chirosca
> <alecsandru.chiro To
> sca@comtec.ro> axis-user@ws.apache.org
> cc
> 04/25/2005 09:48
> AM Subject
> SOAP Body and Header response
>
> Please respond to
> axis-user@ws.apac
> he.org
>
>
>
>
>
>
> Hi,
>
> Please help me wth this one....
>
> I tryed and googled a lot in the last 10 days without any result. I need
> to return a SOAP response that is containing informations in both SOAP
> header and SOAP body. I have the beans that correctly serialize to the
> elements in header and boby but I cannot put them togheter.
>
> Please point me in the right direction here...
>
>
> BR,
> Alecs
>
>
>
Re: SOAP Body and Header response
Posted by mm...@aessuccess.org.
Alecs,
If I understand you're question correctly, the following code should help.
Service Side:
String someResponse = "some response";
// Get Response Envelope
SOAPEnvelope responseEnv = ctx.getResponseMessage().getSOAPEnvelope();
// Create Bean
ResponseHeader responseHeader = new ResponseHeader();
responseHeader.setValue1("Value1");
responseHeader.setValue2("Value2");
...
// Create SOAP Header Element
SOAPHeaderElement responseHeaderElement = new
SOAPHeaderElement("http://www.somedomainname.com", "ResponseHeader",
responseHeader);
or
SOAPHeaderElement responseHeaderElement = new
SOAPHeaderElement("http://www.somedomainname.com", "ResponseHeader");
responseHeaderElement.setObjectValue(responseHeader);
// Add header to response envelope
responseEnv.addHeader(responseRoutingElement);
return response;
Client Side is similar:
// After the invoke
//Get the response envelope
SOAPEnvelope returnEnv =
call.getMessageContext().getResponseMessage().getSOAPEnvelope();
//Get the header with the same names that you put it into the SOAP with.
SOAPHeaderElement responseHeaderElement =
returnEnv.getHeaderByName("http://www.somedomainname.com","ResponseHeader");
//Grab the object out of the header element.
responseHeader = null;
if(responseHeaderElement != null)
{
// Get the bean from the SOAP...
responseHeader = (ResponseHeader)
responseHeaderElement.getObjectValue();
// Do whatever you need to do.
}
else
{
// Trouble
System.out.println("headerElement = null");
}
You need to make sure you have your bean serialization/deserialization
set-up correctly on both ends.
The response will be in the return value from the invoke...
Mark A. Malinoski
AES/PHEAA
Technical Coordinator/Web Development
717-720-2413
mmalinos@aessuccess.org
Alecsandru
Chirosca
<alecsandru.chiro To
sca@comtec.ro> axis-user@ws.apache.org
cc
04/25/2005 09:48
AM Subject
SOAP Body and Header response
Please respond to
axis-user@ws.apac
he.org
Hi,
Please help me wth this one....
I tryed and googled a lot in the last 10 days without any result. I need
to return a SOAP response that is containing informations in both SOAP
header and SOAP body. I have the beans that correctly serialize to the
elements in header and boby but I cannot put them togheter.
Please point me in the right direction here...
BR,
Alecs