Re: AW: How to retrieve SOAP Header in Axis2

weihca <[email protected]>
Newsgroups gmane.text.xml.axis.user
Message-ID <[email protected]>
Hi, I got the null for the header. Following are my code: Thanks in advance
for any help

public OMElement SubmitReq(OMElement element) throws XMLStreamException {
        
		try{

				MessageContext cMessageContext =
MessageContext.getCurrentMessageContext();
				org.apache.axiom.soap.SOAPBody cSOAPBody =
cMessageContext.getEnvelope().getBody();
				
				System.out.println("cSOAPBody="+cSOAPBody.getFirstElementLocalName());
				SOAPHeader header = cMessageContext.getEnvelope().getHeader();
				System.out.println("header="+header);
				Iterator it = header.examineAllHeaderBlocks();

				 while(it.hasNext())
                {
					System.out.println("header");
					/*
                    SOAPHeaderElement element =(SOAPHeaderElement)it.next();
                    Name name = element.getElementName();
                    System.out.println("SOAPHeaderElement element name = " +
name.toString());
                    System.out.println("SOAPHeaderElement node name/value =
" + element.getNodeName()  + " " + element.getNodeValue());
                    System.out.println("SOAPHeaderElement element prefix = "
+ element.getPrefix());
                   */
                }

			}catch(Exception e)
			{
				e.printStackTrace();
			}



Falko-Germar.Schwarz.extern wrote:
> 
> Try the following:
> 
> org.apache.axiom.soap.SOAPHeader header =
> org.apache.axis2.context.MessageContext
> 					.getCurrentMessageContext().getEnvelope().getHeader();
> 
> The getCurrentMessageContext Method is static so you can access the
> MessageContext from nearly everywhere within the message processing flow.
> 
> if you want to receive a dedicated header element you might want to use:
> 
> OMElement headerElem = header.getFirstChildWithName(new QName(
> 					"http://yourname.space", "YourTag"));
> 
> 
> 
> 	Falko-Germar Schwarz (IBM)
> 	HIS16ES 
> 	 
> 	im Auftrage der 
> 	HVB Information Services GmbH
> 	Am Tucherpark 12
> 	D-80538 München
> 	 
> 	phone             +49 89 378-22001
> 	mobil               +49 0170 79 37 26 1
> 	postal address Am Tucherpark 12, D-80538 München
> mailto:[email protected]
> http://www.hvbis.com/
> mailto:[email protected]
> http://www.ibm.com/
> 
> 	HVB Information Services GmbH Member of UniCredit Group, Am Tucherpark
> 12, 80538 München 
> 	Management: Gabriele Ruf, Klaus Rausch 
> 	Chairman Supervisory Board: Matthias Sohler 
> 	Legal form: GmbH, Registered Office: Munich, Register Court: Local Court
> Munich HR B 93804, Tax Number 143/102/30511
> 	Important Note: This e-mail is only intended for the person or
> company/organisation named as recipient. It may contain trade secrets or
> undisclosed and confidential information or information otherwise
> protected by work-product immunity or other legal regulations. If you have
> received this email by mistake, we kindly ask you not to copy this message
> or use it for any purpose nor disclose its contents to any other person.
> Please inform us immediately and delete the original document. In
> addition, please let us know if you or your company object to receiving
> e-mails for messages of this kind. 
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: shirene [mailto:[email protected]] 
> Gesendet: Dienstag, 12. Juni 2007 03:19
> An: [email protected]
> Betreff: Re: How to retrieve SOAP Header in Axis2
> 
> 
> 
> how to get msgContext? do u hv any sample to share?
> 
> 
> Jack Sprat wrote:
>> 
>> Try the following to access the SOAP header:
>> 
>> SOAPEnvelope env = msgContext.getEnvelope();
>> 
>> Regards,
>> T
>> 
>> 
>> shirene <[email protected]> wrote:
>> Hi,
>> Did anyone can help me on how to retrieve the soap header in axis2? 
>> Below is my service.xml file details:
>> 
>> 
>>     
>> 
>> locked="false">ReceiverService
>> 
>>     
>>      
>> class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
>>          urn:soapRec
>>     
>> 
>> 
>> if i use OMElement  as incoming parameter, my web service is working 
>> but i not able to retrieve the soap header. public OMElement 
>> soapRec(OMElement element) {}
>> 
>> In order to retrieve the soap header, i change the function to below
>> method:-
>> public void soapRec(SOAPEnvelope req, SOAPEnvelope resp){}
>> 
>> but i get this error when i call the web service:-
>> 
>> 
>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
>> />soapenv:ClientRaw
>> Xml provider supports only the methods bearing the signature public 
>> OMElement &lt;method-name&gt;(OMElement) where the method name can be 
>> anythingorg.apache.axis2.AxisFault: Raw Xml provider supports only the 
>> methods bearing the signature public OMElement 
>> &lt;method-name&gt;(OMElement) where the method name can be anything
>>  at
>> org.apache.axis2.receivers.RawXMLINOutMessageReceiver.invokeBusinessLogic(RawXMLINOutMessageReceiver.java:95) 
>>  at
>> org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:37) 
>>  at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:454) 
>>  at
>> org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:284) 
>>  at
>> org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:136) 
>>  at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
>>  at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) 
>>  at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) 
>> 
>> 
>> Is that cos by the invalid "messageReceiver" type? if yes, what shld i 
>> change it to?
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>        
>> ---------------------------------
>> Choose the right car based on your needs.  Check out Yahoo! Autos new 
>> Car Finder tool.
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/How-to-retrieve-SOAP-Header-in-Axis2-tf3900058.html#a11071500
> Sent from the Axis - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/How-to-retrieve-SOAP-Header-in-Axis2-tp11056343p34650184.html
Sent from the Axis - User mailing list archive at Nabble.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.