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 Mark <ma...@yahoo.com> on 2003/12/17 16:54:10 UTC

Passing info on SOAP header

Hi
How do I pass info on soap header ? I need to pass some info and want to be able to retrieve it from a provider...Pls guide me to some sample code...

Dimuthu Leelarathne <mu...@opensource.lk> wrote:
Hi Mark,

You can do the same thing as we did, when we implemented AxisMora.

Let's call what you return from your web service as "ReturnValue".

Step 1:: Register your result in the "DefaultTypeMappingImpl"

In "org.apache.axis.encoding.DefaultTypeMappingImpl" you have to register
the your "ResultValue" object.

For example, in our AxisMora, all the web services return values that
implement the "org.apache.axismora.encoding.Serializable.java". We have
written the following code in the DefaultTypeMappingImpl.

myRegister(org.apache.axismora.Constants.SOAP_RESULT,
org.apache.axismora.encoding.Serializable.class,
new org.apache.axismora.encoding.SerializableSerializerFactory(),
null);

You can look at the code at;
http://cvs.apache.org/viewcvs.cgi/ws-axis/contrib/axismora/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java

Step 2:: Set the "ResultValue" to the SOAPBody as below,

SOAPBodyElement bo = new SOAPBodyElement();
bo.setObjectValue(this.resultValue);

Then you have to set this SOAPBody to SOAPEnvelope and call the
"output(SerializationContext )" method of the SOAP envelope and flush the
writer you have set in the SerializationContext.

You can look at;
http://cvs.apache.org/viewcvs.cgi/ws-axis/contrib/axismora/src/org/apache/axismora/soap/BasicMessageContext.java

There should be slight variations from this mehtod, because we keep
soapHeaders and bodies seprately, but basically Axis keeps them together.
But this method shows you basically that you have to do.

Best Regards,
Dimuthu.
-- 
Lanka Software Foundation http://www.opensource.lk

> Hi
> I have a SOAP client which uses my own provider. In the provider I call
> another method - not through the method.invoke but through other means.
> But I want to send the reply through a SOAP msg. So is there a way for
> me to add the return value into the SOAP msg and reconstruct the SOAP
> reply msg? Can I use messageContext for that? Can someon pls point me to
> code samples?
>
>
>
> thanks
> Mark
>
>
> ---------------------------------
> Do you Yahoo!?
> Free Pop-Up Blocker - Get it now




---------------------------------
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing