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 Alastair Fettes <af...@mdacorporation.com> on 2007/12/10 23:30:21 UTC

[Axis2] Server response message headers

We are using WSDL-2-Code generated SkeletonInterface/MessageReceiverInOut
classes in our Apache Axis2 v1.3 doc/lit SOAP 1.2 based web service.  We are
attempting to set headers for the response message that will be used for
traceability within our SOA system.

>From what I can see there is nowhere for us to set headers that will
actually be retained in the response SOAP message.  For example, let me show
the simple case of copying input headers to the output message.

<snippet>
MessageContext inMessageContext =
    MessageContext.getCurrentMessageContext();
OperationContext operationContext =
    inMessageContext.getOperationContext();

MessageContext outMessageContext =
    operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE
);

org.apache.axis2.description.AxisMessage inMessage =
    inMessageContext.getAxisMessage();
org.apache.axis2.description.AxisMessage outMessage =
    outMessageContext.getAxisMessage();

for (Iterator it = inMessage.get; it.hasNext();)
{
    SOAPHeaderMessage header = (SOAPHeaderMessage )it.next();
    outMessage.addSoapHeader(header);
}
</snippet>

This code does not seem to work.  Also, if I simply add new
SOAPHeaderMessage objects that I create manually I can set their qname, etc
but how do I set the _contents_ of this header?

Example header:

<soapenv:Header>
    <Server xmlns="foo.org">bar.server.com</Server>
</soapenv:Header>

Thanks in advance.

Alastair Fettes
MacDonald, Dettwiler and Associates
afettes at mdacorporation dot com

This e-mail and any attachments are intended solely for the use of the
intended recipient(s) and may contain legally privileged, proprietary and/or
confidential information.  Any use, disclosure, dissemination, distribution
or copying of this e-mail and any attachments for any purposes that have not
been specifically authorized by the sender is strictly prohibited.  If you
are not the intended recipient, please immediately notify the sender by
reply e-mail and permanently delete all copies and attachments.

The entire content of this e-mail is for "information purposes" only and
should not be relied upon by the recipient in any way unless otherwise
confirmed in writing by way of letter or facsimile.

Re: [Axis2] Server response message headers

Posted by gaurav lall <le...@gmail.com>.
This links confirms that for the synchronous header you need to write your
own message reciever or add your own handler
http://marc.info/?l=axis-user&m=118701968113313&w=2
Thanks
Gaurav
On Dec 27, 2007 1:55 AM, gaurav lall <le...@gmail.com> wrote:

> I am assuming that you are writing the code as described below in the
> skeleton classes. This will not work as the generated
> SkeletonInterface/MessageReceiever responsibilty is to invoke the business
> logic (skelton class) and construct the soap envelope [
> As per my understanding  the assumption here  is that skelton classes will
> never change headers, as the subsequent generated code calls  the method
> toEnvelope which has the following
> org.apache.axiom.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope
> ();
>  if (param != null) {
>             envelope.getBody().addChild(toOM(param, optimizeContent));
>         }
>
> }
>
> ]
> So the generated code does not give flexibility to provider of the service
> to change header at this point in the flow. This leads to the question as to
> how can the service provider provide a custom header at this point using the
> generated code.
> There are few things which you can try is
> 1.change the generated class (recieverinout ) class so you construct the
> header and envelope.
> 2. The second option which is more logical to me seems to be adding an
> handler class which add the header after the business logic has been done .
> Refer
> http://ws.apache.org/axis2/1_3/modules.html.
> <http://ws.apache.org/axis2/1_3/modules.html>
> Actually I am in the same boat trying to figure out how we can send the
> custom header in the response.
>
>
>
> On Dec 10, 2007 2:30 PM, Alastair Fettes <af...@mdacorporation.com>
> wrote:
>
> > We are using WSDL-2-Code generated
> > SkeletonInterface/MessageReceiverInOut classes in our Apache Axis2 v1.3doc/lit SOAP
> > 1.2 based web service.  We are attempting to set headers for the
> > response message that will be used for traceability within our SOA system.
> >
> > From what I can see there is nowhere for us to set headers that will
> > actually be retained in the response SOAP message.  For example, let me show
> > the simple case of copying input headers to the output message.
> >
> > <snippet>
> > MessageContext inMessageContext =
> >     MessageContext.getCurrentMessageContext();
> > OperationContext operationContext =
> >     inMessageContext.getOperationContext();
> >
> > MessageContext outMessageContext =
> >     operationContext.getMessageContext(
> > WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
> >
> > org.apache.axis2.description.AxisMessage inMessage =
> >     inMessageContext.getAxisMessage();
> > org.apache.axis2.description.AxisMessage outMessage =
> >     outMessageContext.getAxisMessage();
> >
> > for (Iterator it = inMessage.get; it.hasNext();)
> > {
> >     SOAPHeaderMessage header = (SOAPHeaderMessage )it.next();
> >     outMessage.addSoapHeader(header);
> > }
> > </snippet>
> >
> > This code does not seem to work.  Also, if I simply add new
> > SOAPHeaderMessage objects that I create manually I can set their qname, etc
> > but how do I set the _contents_ of this header?
> >
> > Example header:
> >
> > <soapenv:Header>
> >     <Server xmlns="foo.org">bar.server.com</Server>
> > </soapenv:Header>
> >
> > Thanks in advance.
> >
> > Alastair Fettes
> > MacDonald, Dettwiler and Associates
> > afettes at mdacorporation dot com
> >
> > This e-mail and any attachments are intended solely for the use of the
> > intended recipient(s) and may contain legally privileged, proprietary and/or
> > confidential information.  Any use, disclosure, dissemination, distribution
> > or copying of this e-mail and any attachments for any purposes that have not
> > been specifically authorized by the sender is strictly prohibited.  If you
> > are not the intended recipient, please immediately notify the sender by
> > reply e-mail and permanently delete all copies and attachments.
> >
> > The entire content of this e-mail is for "information purposes" only and
> > should not be relied upon by the recipient in any way unless otherwise
> > confirmed in writing by way of letter or facsimile.
> >
> >
> >
>

Re: [Axis2] Server response message headers

Posted by gaurav lall <le...@gmail.com>.
I am assuming that you are writing the code as described below in the
skeleton classes. This will not work as the generated
SkeletonInterface/MessageReceiever responsibilty is to invoke the business
logic (skelton class) and construct the soap envelope [
As per my understanding  the assumption here  is that skelton classes will
never change headers, as the subsequent generated code calls  the method
toEnvelope which has the following
org.apache.axiom.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope();
 if (param != null) {
            envelope.getBody().addChild(toOM(param, optimizeContent));
        }

}

]
So the generated code does not give flexibility to provider of the service
to change header at this point in the flow. This leads to the question as to
how can the service provider provide a custom header at this point using the
generated code.
There are few things which you can try is
1.change the generated class (recieverinout ) class so you construct the
header and envelope.
2. The second option which is more logical to me seems to be adding an
handler class which add the header after the business logic has been done .
Refer
http://ws.apache.org/axis2/1_3/modules.html.
<http://ws.apache.org/axis2/1_3/modules.html>
Actually I am in the same boat trying to figure out how we can send the
custom header in the response.


On Dec 10, 2007 2:30 PM, Alastair Fettes <af...@mdacorporation.com> wrote:

> We are using WSDL-2-Code generated SkeletonInterface/MessageReceiverInOut
> classes in our Apache Axis2 v1.3 doc/lit SOAP 1.2 based web service.  We
> are attempting to set headers for the response message that will be used for
> traceability within our SOA system.
>
> From what I can see there is nowhere for us to set headers that will
> actually be retained in the response SOAP message.  For example, let me show
> the simple case of copying input headers to the output message.
>
> <snippet>
> MessageContext inMessageContext =
>     MessageContext.getCurrentMessageContext();
> OperationContext operationContext =
>     inMessageContext.getOperationContext();
>
> MessageContext outMessageContext =
>     operationContext.getMessageContext(
> WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
>
> org.apache.axis2.description.AxisMessage inMessage =
>     inMessageContext.getAxisMessage();
> org.apache.axis2.description.AxisMessage outMessage =
>     outMessageContext.getAxisMessage();
>
> for (Iterator it = inMessage.get; it.hasNext();)
> {
>     SOAPHeaderMessage header = (SOAPHeaderMessage )it.next();
>     outMessage.addSoapHeader(header);
> }
> </snippet>
>
> This code does not seem to work.  Also, if I simply add new
> SOAPHeaderMessage objects that I create manually I can set their qname, etc
> but how do I set the _contents_ of this header?
>
> Example header:
>
> <soapenv:Header>
>     <Server xmlns="foo.org">bar.server.com</Server>
> </soapenv:Header>
>
> Thanks in advance.
>
> Alastair Fettes
> MacDonald, Dettwiler and Associates
> afettes at mdacorporation dot com
>
> This e-mail and any attachments are intended solely for the use of the
> intended recipient(s) and may contain legally privileged, proprietary and/or
> confidential information.  Any use, disclosure, dissemination, distribution
> or copying of this e-mail and any attachments for any purposes that have not
> been specifically authorized by the sender is strictly prohibited.  If you
> are not the intended recipient, please immediately notify the sender by
> reply e-mail and permanently delete all copies and attachments.
>
> The entire content of this e-mail is for "information purposes" only and
> should not be relied upon by the recipient in any way unless otherwise
> confirmed in writing by way of letter or facsimile.
>
>
>