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 weihca <we...@intertek.com> on 2012/11/07 03:00:53 UTC

Re: AW: How to retrieve SOAP Header in Axis2

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:Falko-Germar.Schwarz.extern@HVBIS.com
> http://www.hvbis.com/
> mailto:falkoschwarz@de.ibm.com
> 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:tracy_yau@hotmail.com] 
> Gesendet: Dienstag, 12. Juni 2007 03:19
> An: axis-user@ws.apache.org
> 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 <tr...@hotmail.com> 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: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> 
> 

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


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org