Here is sample code to use MessageContext,,,(after the necessary imports of course)
 
 
MessageContext msgContext = MessageContext.getCurrentContext();
  //get the servlet request
HttpServletRequest request = (HttpServletRequest)msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
(There need not be a web based "viewable" application for you to use HttpServletRequest. I tested on Tomcat with Axis for my webservice that doesn't have any servlet or JSP made by me)

...
...
 
 request.getAttribute("javax.servlet.request.CLASS_TO_GET_INFO_FROM");
 
---------------------
Rommel.
----- Original Message -----
Sent: Wednesday, January 14, 2004 8:26 AM
Subject: Re: Accessing SOAP Message Header

I believe you can use http://ws.apache.org/axis/java/apiDocs/org/apache/axis/MessageContext.html#getCurrentContext()
to get the current MessageContext which will point you to just about everything Axis knows about the message.

http://ws.apache.org/axis/java/apiDocs/org/apache/axis/MessageContext.html#getMessage()
http://ws.apache.org/axis/java/apiDocs/javax/xml/soap/SOAPMessage.html#getMimeHeaders()

Ransel Lopez wrote:
Hi all:
 
How can I access to the header of a client request?? I mean, for example: my client always send me some information and I don't need it like a parameter (for example a sessionID). Clients are going to send that info as a header parameter. How can I acces that info at the server side??
 
Example:
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-16"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
        xmlns:tns="http://localhost:8080/mycompany/services/myservice"
        xmlns:types="http://localhost:8080/mycompany/services/myservice/encodedTypes"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <soap:Header>
   <tns:headerStruct id="session_id">
     <session_id xsi:type="xsd:string">DguSIHKFbhUZJygsKissLUR2MxA=</session_id>
   </tns:headerStruct>
 </soap:Header>
 <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
   <q1:logout xmlns:q1="http://my.company.com">
   </q1:logout>
 </soap:Body>
</soap:Envelope>
In red is the info that I need to access
 
Thank you for you help!!!

Ransel L�pez, Web Services Developer

Time Industrial, Inc.
 An Outsourced Contractor Time and Cost Tracking Service.
 -----------------------------------------------------------------------------------------
tel: 780.413.1521  fax: 780.413.0474
 http://www.TimeIndustrial.com

 -----------------------------------------------------------------------------------------
 This message and attached files, if any, is (are) intended only for the addressee(s) and may 
 contain privileged or confidential information. Any unauthorized disclosure is strictly prohibited. 
 If destined to our legal counsel, this transmission is privileged communication as between an 
 attorney and its client.
 If you have received this message in error, please notify us immediately so that we may correct 
 our internal records. Please then delete the original message. Thank you.

 
 

 

*********************************************************
Disclaimer

This message (including any attachments) contains
confidential information intended for a specific
individual and purpose, and is protected by law.
If you are not the intended recipient, you should
delete this message and are hereby notified that
any disclosure, copying, or distribution of this
message, or the taking of any action based on it,
is strictly prohibited.

*********************************************************
Visit us at http://www.mahindrabt.com

Reply via email to