You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Ne...@wellsfargo.com on 2013/04/12 20:06:28 UTC

Seperate CXF client configuration from CXF server configuration

My application is a web service Server using CXF SOAP stack and running in Tomcat.
The server uses  /cxf.xml (in classpath) to configure server logging interceptor.
Now, the server needs to invoke other web service server as a client.
Business requires has different requirement to client logging vs. server logging.
We have to define a client logging interceptor which is different from server logging interceptor.

How do I configure a client logging interceptor besides a server logging interceptor.

Based on Apache document, both CXF server and client will use same /cxf.xml file.
With Axis, there are two configuration files: one for server and the other for client.
But, with CXF, I do not see server cxf.xml and client cxf.xml.

Thanks



Ed Xu
Community Bank Technology (CBT); Enterprise Business Services Technology (EBST)

225 2nd Ave. S. Mpls, MN 55479
Phone (612) 667-6489; Fax:(612) 667-8092
MAC: N9301-028
"This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation."




RE: Seperate CXF client configuration from CXF server configuration

Posted by Ne...@wellsfargo.com.
Thanks Fang although I do not have time to test it out due to some other produciton issue.

Will do testing soon

-----Original Message-----
From: Freeman Fang [mailto:freeman.fang@gmail.com] 
Sent: Monday, April 15, 2013 7:33 PM
To: users@cxf.apache.org
Subject: Re: Seperate CXF client configuration from CXF server configuration

Hi,

Before your client code, I think you can add something like


        SpringBusFactory factory = new SpringBusFactory();
        Bus bus = factory.createBus(
            "your_client_specific_bus_cfg.xml"
        );
        BusFactory.setDefaultBus(bus);
So that your client can use a client specific bus.
And before your server code, you can have similar thing to specify a server specific bus

Moreover, even your client and server load same interceptors, you still can use MessageUtils.isRequestor(message)(true for client) to determine if it's client or server
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: @Freeman小屋

On 2013-4-15, at 下午11:03, neng1998 wrote:

> Hi
> I did in int code as following
>        	URL wsdlUrl =
> EpsilonWSClientFactory.class.getClassLoader().getResource("../wsdl/com/wellsfargo/service/provider/ebs/epsilon/epsilonService2013.wsdl");
>        	EpsilonService2013 service = new EpsilonService2013(wsdlUrl);
>    		wsport = service.getEpsilonService2013();    		
>    		BindingProvider provider = (BindingProvider) wsport;
>    		ClientLoggingInInterceptor clin = new ClientLoggingInInterceptor();
>    		ClientProxy.getClient(wsport).getOutInterceptors().add(clin);
>    	
> provider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROP
> ERTY,
> getUrl());
>    		setupTLS(wsport);
> 
> As you see, I add a ClientLoggingInInterceptor.  
> 
> The Server is configured with cxf.xml as following <cxf:bus name>
>        <cxf:inInterceptors>
>                     <ref bean="logInbound"/> 
>        </cxf:inInterceptors>
>        <cxf:outInterceptors>
>                      <ref bean="logOutbound"/>
>       </cxf:outInterceptors>    
> </cxf:bus>
> 
> 
> I saw both client and server  interceptors are invoked when 
> Application working as CXF client sent SOAP message.
> 
> 
> Ed
> 
> 
> 
> --
> View this message in context: 
> http://cxf.547215.n5.nabble.com/Seperate-CXF-client-configuration-from
> -CXF-server-configuration-tp5726238p5726330.html
> Sent from the cxf-user mailing list archive at Nabble.com.


Re: Seperate CXF client configuration from CXF server configuration

Posted by Freeman Fang <fr...@gmail.com>.
Hi,

Before your client code, I think you can add something like


        SpringBusFactory factory = new SpringBusFactory();
        Bus bus = factory.createBus(
            "your_client_specific_bus_cfg.xml"
        );
        BusFactory.setDefaultBus(bus);
So that your client can use a client specific bus.
And before your server code, you can have similar thing to specify a server specific bus

Moreover, even your client and server load same interceptors, you still can use
MessageUtils.isRequestor(message)(true for client) to determine if it's client or server
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: @Freeman小屋

On 2013-4-15, at 下午11:03, neng1998 wrote:

> Hi
> I did in int code as following
>        	URL wsdlUrl =
> EpsilonWSClientFactory.class.getClassLoader().getResource("../wsdl/com/wellsfargo/service/provider/ebs/epsilon/epsilonService2013.wsdl");
>        	EpsilonService2013 service = new EpsilonService2013(wsdlUrl);
>    		wsport = service.getEpsilonService2013();    		
>    		BindingProvider provider = (BindingProvider) wsport;
>    		ClientLoggingInInterceptor clin = new ClientLoggingInInterceptor();
>    		ClientProxy.getClient(wsport).getOutInterceptors().add(clin);
>    	
> provider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
> getUrl());
>    		setupTLS(wsport); 
> 
> As you see, I add a ClientLoggingInInterceptor.  
> 
> The Server is configured with cxf.xml as following
> <cxf:bus name>
>        <cxf:inInterceptors>
>                     <ref bean="logInbound"/> 
>        </cxf:inInterceptors>
>        <cxf:outInterceptors>
>                      <ref bean="logOutbound"/>
>       </cxf:outInterceptors>    
> </cxf:bus>
> 
> 
> I saw both client and server  interceptors are invoked when Application
> working as CXF client sent SOAP message.
> 
> 
> Ed
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Seperate-CXF-client-configuration-from-CXF-server-configuration-tp5726238p5726330.html
> Sent from the cxf-user mailing list archive at Nabble.com.


Re: Seperate CXF client configuration from CXF server configuration

Posted by neng1998 <Ne...@wellsfargo.com>.
Hi
I did in int code as following
        	URL wsdlUrl =
EpsilonWSClientFactory.class.getClassLoader().getResource("../wsdl/com/wellsfargo/service/provider/ebs/epsilon/epsilonService2013.wsdl");
        	EpsilonService2013 service = new EpsilonService2013(wsdlUrl);
    		wsport = service.getEpsilonService2013();    		
    		BindingProvider provider = (BindingProvider) wsport;
    		ClientLoggingInInterceptor clin = new ClientLoggingInInterceptor();
    		ClientProxy.getClient(wsport).getOutInterceptors().add(clin);
    	
provider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
getUrl());
    		setupTLS(wsport); 

As you see, I add a ClientLoggingInInterceptor.  

The Server is configured with cxf.xml as following
<cxf:bus name>
        <cxf:inInterceptors>
                     <ref bean="logInbound"/> 
        </cxf:inInterceptors>
        <cxf:outInterceptors>
                      <ref bean="logOutbound"/>
       </cxf:outInterceptors>    
</cxf:bus>


I saw both client and server  interceptors are invoked when Application
working as CXF client sent SOAP message.


Ed



--
View this message in context: http://cxf.547215.n5.nabble.com/Seperate-CXF-client-configuration-from-CXF-server-configuration-tp5726238p5726330.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Seperate CXF client configuration from CXF server configuration

Posted by Freeman Fang <fr...@gmail.com>.
I believe you can specify a specific bus for the client, where you can add interceptors only used by the client.

There are several ways to do so, depend on how you initialize your client, you need let us know how you initialize your client
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: @Freeman小屋

On 2013-4-15, at 下午9:18, neng1998 wrote:

> Thanks. Indeed, I know these.
> The problem is that the logger interceptors configured for server are still
> invoked while doing client call. 
> CXF process SOAP message via interceptors chain. (inbound and outbound).
> What I am looking for is to configure a set of intercetor chain (inbound and
> outbound) for server and another set of intercetor chain for client.  Axis
> support it. but I do not think CXF does it. 
> 
> 
> Ed. 
> 
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Seperate-CXF-client-configuration-from-CXF-server-configuration-tp5726238p5726311.html
> Sent from the cxf-user mailing list archive at Nabble.com.


RE: Seperate CXF client configuration from CXF server configuration

Posted by neng1998 <Ne...@wellsfargo.com>.
Thanks. Indeed, I know these.
The problem is that the logger interceptors configured for server are still
invoked while doing client call. 
CXF process SOAP message via interceptors chain. (inbound and outbound).
What I am looking for is to configure a set of intercetor chain (inbound and
outbound) for server and another set of intercetor chain for client.  Axis
support it. but I do not think CXF does it. 


Ed. 




--
View this message in context: http://cxf.547215.n5.nabble.com/Seperate-CXF-client-configuration-from-CXF-server-configuration-tp5726238p5726311.html
Sent from the cxf-user mailing list archive at Nabble.com.

RE: Seperate CXF client configuration from CXF server configuration

Posted by Andrei Shakirin <as...@talend.com>.
Hi,

You can add client specific interceptors programmatically using this code:

MyInterceptor myInterceptor = new MyInterceptor();
FooService client = ... ; 
Client cxfClient = ClientProxy.getClient(client);
cxfClient.getOutInterceptors().add(myInterceptor);
cxfClient.getInInterceptors().add(myInterceptor);

// then you can call the service
client.doSomething();

Cheers,
Andrei.

> -----Original Message-----
> From: Neng.Xu@wellsfargo.com [mailto:Neng.Xu@wellsfargo.com]
> Sent: Freitag, 12. April 2013 20:06
> To: users@cxf.apache.org
> Subject: Seperate CXF client configuration from CXF server configuration
> 
> My application is a web service Server using CXF SOAP stack and running in
> Tomcat.
> The server uses  /cxf.xml (in classpath) to configure server logging
> interceptor.
> Now, the server needs to invoke other web service server as a client.
> Business requires has different requirement to client logging vs. server
> logging.
> We have to define a client logging interceptor which is different from server
> logging interceptor.
> 
> How do I configure a client logging interceptor besides a server logging
> interceptor.
> 
> Based on Apache document, both CXF server and client will use same
> /cxf.xml file.
> With Axis, there are two configuration files: one for server and the other for
> client.
> But, with CXF, I do not see server cxf.xml and client cxf.xml.
> 
> Thanks
> 
> 
> 
> Ed Xu
> Community Bank Technology (CBT); Enterprise Business Services Technology
> (EBST)
> 
> 225 2nd Ave. S. Mpls, MN 55479
> Phone (612) 667-6489; Fax:(612) 667-8092
> MAC: N9301-028
> "This message may contain confidential and/or privileged information. If you
> are not the addressee or authorized to receive this for the addressee, you
> must not use, copy, disclose, or take any action based on this message or any
> information herein. If you have received this message in error, please advise
> the sender immediately by reply e-mail and delete this message. Thank you
> for your cooperation."
> 
>