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 Antonio Iossa <An...@enterpriseda.com> on 2007/01/02 13:11:17 UTC

Modify the SOAP Body

Excuse me... I having a doubt..

Can an handler modify the body of a SOAP message??

The Book "J2EE Web Services" by Richar Monson-Haefel says 


"Neither SOAP 1.1 nor the BP explicity prohibits intermediaries from modifying the contents of the Body element. As a result, the ultimate reciever has no way of knowing if the application specific data has changed somewhere along the message path. SOAP 1.2 reduces this uncertainty by explictly prohibiting certain intermediaries, called forwarding intermediaries, from changing the contents of the Body element and recommeding that all other intermediaries, called active intermiediaries, use a header block to document any chances to the Body element"

Can anyone help me please??

 

 

	-----Original Message----- 
	From: Antonio Iossa 
	Sent: Mon 1/1/2007 2:12 PM 
	To: axis-user@ws.apache.org 
	Cc: 
	Subject: Modify the SOAP Body before a Stub send it
	
	

	Hi all!

	 

	I'm new to Axis. I would modify the body of a SOAP message *before* axis (client-side) send it to a Web Service.

	 

	 

	First of all, I wrote a simple Echo WS:

	 

	public class MyServerOne {

	 

	    public String echo(String msg) {

	        System.out.println("In the WS - Server Side");

	        return "ECHO: % " + msg + " %";

	    }

	} 

	and I deployed it with the following WSDD:

	 

	<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

	 

	  <service name="MyServerOne" provider="java:RPC">

	    <parameter name="className" value="wsSamlTest.server.MyServerOne"/>

	    <parameter name="allowedMethods" value="echo"/>

	    <parameter name="scope" value="Request"/>

	  </service>

	</deployment>

	 

	 

	Further, I developed a simple client-side handler:

	 

	public class myClientHandler extends BasicHandler {

	    public void invoke(MessageContext msgContext) throws AxisFault {

	        try {

	            SOAPEnvelope env = msgContext.getRequestMessage().

	getSOAPEnvelope();

	            

	            SOAPBody body = env.getBody();

	            

	            System.out.println("VALUE before: " + 

	                               body.

	                              getFirstChild().

	                              getFirstChild().

	                              getFirstChild().

	                              getNodeValue() );

	 

	            //set the new value:    

	                                   body.

	                                   getFirstChild().

	                                   getFirstChild().

	                                   getFirstChild().

	                                   setNodeValue("new value");

	 

	            System.out.println("VALUE AFTER: " + 

	                               body.

	                              getFirstChild().

	                              getFirstChild().

	                              getFirstChild().

	                              getNodeValue() );

	          

	        } catch (SOAPException ex) {

	            ex.printStackTrace();

	            throw new AxisFault("myClientHandler",ex);

	        } catch (DOMException ex) {

	            ex.printStackTrace();

	         throw new AxisFault("myClientHandler",ex);

	        }

	    }

	}

	 

	I deployed the previous handler on the flow with the following WSDD:

	 

	<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

	 

	<transport name="http"  pivot="java:org.apache.axis.transport.http.HTTPSender"/>

	<globalConfiguration>

	  <requestFlow>

	    <handler type="java:wsSamlTest.client.myClientHandler" >

	    </handler>

	  </requestFlow>

	</globalConfiguration >

	<transport name="java"  pivot="java:org.apache.axis.transport.java.JavaSender"/>

	<transport name="http" pivot="java:org.apache.axis.transport.http.HTTPSender"/>

	 <transport name="local" pivot="java:org.apache.axis.transport.local.LocalSender"/>

	</deployment>

	 

	 

	 

	The output of the client-side handler is the following:

	 

	VALUE before: Original value

	VALUE after: new value

	

	But the SOAP message sent is the following:

	 

	<?xml version="1.0" encoding="UTF-8"?>

	   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:xsd="http://www.w3.org/2001/XMLSchema"       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

	     <soapenv:Body>

	        <ns1:echo soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://server.wsSamlTest">

	           <msg xsi:type="soapenc:string" xmlns:soapenc=

	             "http://schemas.xmlsoap.org/soap/encoding/">

	             Original value

	           </msg>

	        </ns1:echo>

	     </soapenv:Body>

	</soapenv:Envelope>

	 

	 

	Where I mistake?

	 

	Thanks all in advance... and happy new year!

	 

	Antonio


Re: Modify the SOAP Body

Posted by Anne Thomas Manes <at...@gmail.com>.
Handlers can change the body -- for example, a handler might encrypt
or compress the body.

Anne

On 1/2/07, Antonio Iossa <An...@enterpriseda.com> wrote:
>
>
>
> Excuse me... I having a doubt..
>
> Can an handler modify the body of a SOAP message??
>
> The Book "J2EE Web Services" by Richar Monson-Haefel says
>
>
> "Neither SOAP 1.1 nor the BP explicity prohibits intermediaries from
> modifying the contents of the Body element. As a result, the ultimate
> reciever has no way of knowing if the application specific data has changed
> somewhere along the message path. SOAP 1.2 reduces this uncertainty by
> explictly prohibiting certain intermediaries, called forwarding
> intermediaries, from changing the contents of the Body element and
> recommeding that all other intermediaries, called active intermiediaries,
> use a header block to document any chances to the Body element"
>
> Can anyone help me please??
>
>
>
>
>
> -----Original Message-----
> From: Antonio Iossa
> Sent: Mon 1/1/2007 2:12 PM
> To: axis-user@ws.apache.org
> Cc:
> Subject: Modify the SOAP Body before a Stub send it
>
>
>
>
> Hi all!
>
>
>
> I'm new to Axis. I would modify the body of a SOAP message *before* axis
> (client-side) send it to a Web Service.
>
>
>
>
>
> First of all, I wrote a simple Echo WS:
>
>
>
> public class MyServerOne {
>
>
>
>     public String echo(String msg) {
>
>         System.out.println("In the WS - Server Side");
>
>         return "ECHO: % " + msg + " %";
>
>     }
>
> }
>
> and I deployed it with the following WSDD:
>
>
>
> <deployment xmlns="http://xml.apache.org/axis/wsdd/"
> xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
>
>
>
>   <service name="MyServerOne" provider="java:RPC">
>
>     <parameter name="className" value="wsSamlTest.server.MyServerOne"/>
>
>     <parameter name="allowedMethods" value="echo"/>
>
>     <parameter name="scope" value="Request"/>
>
>   </service>
>
> </deployment>
>
>
>
>
>
> Further, I developed a simple client-side handler:
>
>
>
> public class myClientHandler extends BasicHandler {
>
>     public void invoke(MessageContext msgContext) throws AxisFault {
>
>         try {
>
>             SOAPEnvelope env = msgContext.getRequestMessage().
>
> getSOAPEnvelope();
>
>
>
>             SOAPBody body = env.getBody();
>
>
>
>             System.out.println("VALUE before: " +
>
>                                body.
>
>                               getFirstChild().
>
>                               getFirstChild().
>
>                               getFirstChild().
>
>                               getNodeValue() );
>
>
>
>             //set the new value:
>
>                                    body.
>
>                                    getFirstChild().
>
>                                    getFirstChild().
>
>                                    getFirstChild().
>
>                                    setNodeValue("new
> value");
>
>
>
>             System.out.println("VALUE AFTER: " +
>
>                                body.
>
>                               getFirstChild().
>
>                               getFirstChild().
>
>                               getFirstChild().
>
>                               getNodeValue() );
>
>
>
>         } catch (SOAPException ex) {
>
>             ex.printStackTrace();
>
>             throw new AxisFault("myClientHandler",ex);
>
>         } catch (DOMException ex) {
>
>             ex.printStackTrace();
>
>          throw new AxisFault("myClientHandler",ex);
>
>         }
>
>     }
>
> }
>
>
>
> I deployed the previous handler on the flow with the following WSDD:
>
>
>
> <deployment xmlns="http://xml.apache.org/axis/wsdd/"
> xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
>
>
>
> <transport name="http"
> pivot="java:org.apache.axis.transport.http.HTTPSender"/>
>
> <globalConfiguration>
>
>   <requestFlow>
>
>     <handler type="java:wsSamlTest.client.myClientHandler"
> >
>
>     </handler>
>
>   </requestFlow>
>
> </globalConfiguration >
>
> <transport name="java"
> pivot="java:org.apache.axis.transport.java.JavaSender"/>
>
> <transport name="http"
> pivot="java:org.apache.axis.transport.http.HTTPSender"/>
>
>  <transport name="local"
> pivot="java:org.apache.axis.transport.local.LocalSender"/>
>
> </deployment>
>
>
>
>
>
>
>
> The output of the client-side handler is the following:
>
>
>
> VALUE before: Original value
>
> VALUE after: new value
>
>
>
> But the SOAP message sent is the following:
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
>    <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>
>      <soapenv:Body>
>
>         <ns1:echo
> soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:ns1="http://server.wsSamlTest">
>
>            <msg xsi:type="soapenc:string" xmlns:soapenc=
>
>              "http://schemas.xmlsoap.org/soap/encoding/">
>
>              Original value
>
>            </msg>
>
>         </ns1:echo>
>
>      </soapenv:Body>
>
> </soapenv:Envelope>
>
>
>
>
>
> Where I mistake?
>
>
>
> Thanks all in advance... and happy new year!
>
>
>
> Antonio

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