Shaoguang, MessageContext does not have a "getSoapEnvelope" method, in fact the only getter method it has is getCurrentMessageContext (at least for Axis2). Any other ideas? I think I might switch to XFire to do what I need. I posted over there and it sounds like in the next day or so there will be support for getting the headers that I need.
Thanks Craig On 4/22/07, Thilina Gunarathne <[EMAIL PROTECTED]> wrote:
> Do we have a default envelope set in out message context in Axis2? > In Step #1 what he does is set an envelope in out message context (with the > out headers) first and then retrieve it. > outMessageContext.setEnvelope(createSOAPEnvelope()); see https://issues.apache.org/jira/browse/AXIS2-2531 Thanka, Thilina > > So the Step# 2 suggestion is a performace improvement only if Axis2 set a > default out Envelope. I am not sure whether Axis2 does this or not. if so I > think we have to stop that since there is no reason to do that. > > Amila. > > > thanks, > > dims > > > > On 4/19/07, Kang, Kamaljeet K. < [EMAIL PROTECTED]> wrote: > > > These are the changes I did to get Response SOAP header. > > > > > > 1) Save header in the message context in the skeleton implementation. > > > MessageContext inMsgContext = > MessageContext.getCurrentMessageContext(); > > > OperationContext operationContext = > inMsgContext.getOperationContext(); > > > MessageContext outMessageContext = operationContext > .getMessageContext( WSDLConstants.MESSAGE_LABEL_OUT_VALUE); > > > outMessageContext.setEnvelope(createSOAPEnvelope()); > > > OMNode outHeaderNode = toOM(outHeader); > > > > > > > outMessageContext.getEnvelope().getHeader().addChild(outHeaderNode); > > > > > > 2) Modified autogenerated *InOutReceiver classes to not create new > Envelope if Envelope is already there in the context (modified whereever > factory.getDefaultEnvelope() is called) > > > > > > 3) Modified Stub to save the return message context > > > org.apache.axis2.context.MessageContext > _returnMessageContext = _operationClient.getMessageContext( > > > > org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE > ); > > > org.apache.axiom.soap.SOAPEnvelope > _returnEnv = _returnMessageContext.getEnvelope(); > > > > > > // Added this line > > > > _serviceClient.getServiceContext().setLastOperationContext(_operationClient.getOperationContext()); > > > > > > > > > 4) Finally you can get the Response Header from stub > > > > > > OperationContext oprCtxt = > stub._getServiceClient().getLastOperationContext(); > > > MessageContext inMsgContext = > oprCtxt.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE); > > > SOAPHeader header = inMsgContext.getEnvelope().getHeader(); > > > > > > return > Header_T.Factory.parse(header.getFirstElement ().getXMLStreamReaderWithoutCaching()); > > > > > > Not sure if there is any easier way but finally this worked for me. > > > > > > Let me know if you need more help with this. > > > > > > > > > Kamal Kang > > > > > > > > > -----Original Message----- > > > From: José Antonio Sánchez [mailto:[EMAIL PROTECTED] > > > Sent: Thursday, April 19, 2007 3:56 PM > > > To: [email protected] > > > Subject: Re: Apache Axis 2: how to get header? Options > > > > > > AFAIK you have to modify the stub code and get headers from there. In > > > Axis2 1.2 there is an operation in the generated stub to get the last > > > operation context (and so the envelope object) but it didn't work for > > > me. > > > > > > On 4/19/07, craig wickesser <[EMAIL PROTECTED]> wrote: > > > > anyone??? > > > > > > > > > > > > On 4/18/07, craig wickesser <[EMAIL PROTECTED]> wrote: > > > > > Hi...I have a client which I am using to access a web service The > > > > > code I have is... > > > > > > > > > > > > > > > MyStub stub = new MyStub(); > > > > > HelloWorldDocument reqDoc = > > > > HellWorldDocument.Factory.newInstance (); > > > > > reqDoc.setName("bob"); > > > > > > > > > > > > > > > HelloWorldResponseDocumnet resp = > stub.SayHello(reqDoc); > > > > > > > > > > > > > > > The SOAP XML response is in the following form... > > > > > > > > > > > > > > > <soap12:Envelope ....> > > > > > <soap12:Header> > > > > > <ErrorResponse ....> > > > > > </ErrorResponse> > > > > > <UserInfo ...> > > > > > <Id>string</Id> > > > > > <DOB>string</DOB> > > > > > </UserInfo> > > > > > </soap12:Header> > > > > > <soap12:Body> > > > > > <HelloWorldResponse ....> > > > > > ..... > > > > > </HelloWorldResponse> > > > > > </soap12:Body> > > > > > </soap12:Envelope> > > > > > > > > > > > > > > > My issue is I need to get stuff from the UserInfo header....how can > I > > > > > get that? Currently all I can get is the HelloWorldResponse from > the > > > > > "body". > > > > > > > > > > Thanks! > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > Saludos. > > > José Antonio Sánchez > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > ============================================================ > > > The information contained in this message may be privileged > > > and confidential and protected from disclosure. If the reader > > > of this message is not the intended recipient, or an employee > > > or agent responsible for delivering this message to the > > > intended recipient, you are hereby notified that any reproduction, > > > dissemination or distribution of this communication is strictly > > > prohibited. If you have received this communication in error, > > > please notify us immediately by replying to the message and > > > deleting it from your computer. Thank you. Tellabs > > > > ============================================================ > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > -- > > Davanum Srinivas :: http://wso2.org/ :: Oxygen for Web Services Developers > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > -- > Amila Suriarachchi, > WSO2 Inc. -- Thilina Gunarathne - http://www.wso2.com - http://thilinag.blogspot.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
