• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to add header to soap response using axis2 and java?

 
Sanjoy De
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to add header to soap response using axis2? I have a client ----

and a service from where the header will be set as soap response as -



But the response message I am getting as -

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header/><soapenv:Body><ns:sendResponseOrAckResponse xmlns:ns="http://service.ttg.tcs.com/xsd"><ns:return>org.apache.axis2.saaj.SOAPMessageImpl@179953c</ns:return></ns:sendResponseOrAckResponse></soapenv:Body></soapenv:Envelope>

In the response message see that the header is blank. I want the headers under the header tag and the body contents under the body tag. Right now the entire response comes under body tag.

Please help me to solve the problem.

Thanks in advance.
 
Kesava Krishna
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sanjoy,

Please use AbstractHandler. Write a class extending AbstractHandler and orverride invoke() method. Invoke method will provide you with a provision to get soap envelope and set header in the response.

Thanks,
Kesava
 
Sanjoy De
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kesava,

Thanks for your quick reply. Actually im new to webservice, so, can you please give me an example for adding header to soap message response?
That will be very helpful.

Thanks
 
Sanjoy De
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Kesava,

I have written a Handler, but dont know how to use that inside a webservice and how to call. Can you please help me?


Thanks,
Sanjoy
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code would not call the handler explicitly. You would declare the handler as part of the request and/or response flow in the client-side and/or server-side deployment descriptors (the WSDD files).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!