cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: CXF Interceptor Header
Date Thu, 23 Sep 2010 01:57:09 GMT

When that interceptor runs, that just prints something like:

name : userName

Right?

Basically, you'll need to get the object out of the Header object.   It's most 
likely a DOM so you'll need to get the text content from that dom.

Dan

On Monday 20 September 2010 11:33:22 am willoi wrote:
> Hi,
> 
> I have a webapp using CXF and  Spring,i am tryng to put an interceptor in
> order to get parameters from Soap Header
> 
> I don't really have problem  with interceptor and its configuration
> 
> My main problem occurs when i'am tryng to get message from SoapMessage
> class, especially for parameters which are contained in header. (See
> example below userName parameter)
> 
> Can you tell me how i must use the message parameter in handleMessage
> method?
> Did i forget anything ?
> 
> 
> Here is the  message soap sent :
> 
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:spr="http://springtest.***.com/">
>    <soapenv:Header>
> 
>          <userName>John Doe</userName>
> 
>    </soapenv:Header>
>    <soapenv:Body>
>       <spr:oneMethod>
>          <!--Optional:-->
>          <arg0>10</arg0>
>          <!--Optional:-->
>          <arg1>20</arg1>
>       </spr:oneMethod>
>    </soapenv:Body>
> </soapenv:Envelope>
> 
> interceptor class:
> 
> 
> public class TestInterceptor extends AbstractSoapInterceptor{
> 	String userConnected="";
> 
> 	  public TestInterceptor() {
> 		    super(Phase.READ);
> 		  }
> 
> 
> 	@Override
> 	public void handleMessage(SoapMessage message) {
> 		System.out.println("interceptor");
> 
> 		List<Header> headers=message.getHeaders();
> 
> 		for (Header header:headers){
> 			System.out.println("name : " +  header.getName());
> 		}
> 
> 
> 	}
> 
> }
> 
> And interceptor configuration for  Spring
> 
> 	<bean id="testInterceptor" class="com.***.springtest.TestInterceptor"/>
> 
>     <!-- We are adding the interceptors to the bus as we will have only one
> endpoint/service/bus. -->
> 
>     <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl">
>         <property name="inInterceptors">
>             <ref bean="testInterceptor"/>
>         </property>
>         <property name="outInterceptors">
>             <ref bean="testInterceptor"/>
>         </property>
>     </bean>

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

Mime
View raw message