You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Alex Shneyderman <a....@gmail.com> on 2011/11/23 12:58:17 UTC

Client stub that does not call the actual end point.

Hello,

I have a requirement where I need to configure a client proxy that
does not actually make http request to the endpoint. We use
org.apache.cxf.jaxws.JaxWsProxyFactoryBean to instantiate client
proxies. Is there a way to instruct the factory to construct proxy in
a way where calls to the remote end point are diverted to the calls to
the local object instance?

I want to preserve all the logging that we have configured on this
proxy (we log request/response soap messages) - not sure if this is
even possible.

Any hints/solutions are greatly appreciated.

Cheers,
Alex.

Re: Client stub that does not call the actual end point.

Posted by Daniel Kulp <dk...@apache.org>.


On Wednesday, November 23, 2011 5:27:34 PM Alex Shneyderman wrote:
> Hi, Daniel!
> 
> Is there any other configuration that needs to be done for this?

You may need to add a transportId property/attribute on them that sets it to:

http://cxf.apache.org/transports/local

Also, if using Maven, make sure you have cxf-rt-transport-local jar available.

Dan


> 
> I configured this:
> 
>     <bean id="mock.clientFactory"
> class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
> 		<property name="serviceClass" value="blah.TroubleTicket" />
> 		<property name="address" value="local://TroubleTicketMock" />
>     </bean>
> 
>     <bean id="blah.TroubleTicketMock"
>           class="blah.p.TroubleTicketMock" />
> 
>     <jaxws:endpoint id="mock.server"
> 		implementor="#blah.TroubleTicketMock"
> 		address="local://TroubleTicketMock">
> 	</jaxws:endpoint>
> 
> on initialization call I get exception:
> 
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'mock.serverr': Invocation of init method
> failed; nested exception is javax.xml.ws.WebServiceException:
> java.lang.NullPointerException
> 	at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactor
> y.initializeBean(AbstractAutowireCapableBeanFactory.java:1338) at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactor
> y.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactor
> y$1.run(AbstractAutowireCapableBeanFactory.java:409) at
> java.security.AccessController.doPrivileged(Native Method)
> 	at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactor
> y.createBean(AbstractAutowireCapableBeanFactory.java:380) at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(A
> bstractBeanFactory.java:264) at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getS
> ingleton(DefaultSingletonBeanRegistry.java:222) at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(Abs
> tractBeanFactory.java:261) at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abstr
> actBeanFactory.java:185) at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abstr
> actBeanFactory.java:164) at
> org.springframework.beans.factory.support.DefaultListableBeanFactory.preIns
> tantiateSingletons(DefaultListableBeanFactory.java:429) at
> org.springframework.context.support.AbstractApplicationContext.finishBeanFa
> ctoryInitialization(AbstractApplicationContext.java:728) at
> org.springframework.context.support.AbstractApplicationContext.refresh(Abst
> ractApplicationContext.java:380) at
> org.springframework.test.AbstractSingleSpringContextTests.createApplication
> Context(AbstractSingleSpringContextTests.java:213) at
> org.springframework.test.AbstractSingleSpringContextTests.loadContextLocati
> ons(AbstractSingleSpringContextTests.java:189) at
> org.springframework.test.AbstractSingleSpringContextTests.loadContext(Abstr
> actSingleSpringContextTests.java:169) at
> org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpri
> ngContextTests.java:140) at
> org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSin
> gleSpringContextTests.java:98) at
> org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.ja
> va:76) at
> com.intellij.junit3.JUnit3IdeaTestRunner.doRun(JUnit3IdeaTestRunner.java:13
> 9) at
> com.intellij.junit3.JUnit3IdeaTestRunner.startRunnerWithArgs(JUnit3IdeaTest
> Runner.java:52) at
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitSt
> arter.java:199) at
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62) at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3
> 9) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
> Caused by: javax.xml.ws.WebServiceException: java.lang.NullPointerException
> at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:350) at
> org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:239) at
> org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:509) at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3
> 9) at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp
> l.java:25) at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactor
> y.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1414) at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactor
> y.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1375) at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactor
> y.initializeBean(AbstractAutowireCapableBeanFactory.java:1335) ... 36 more
> Caused by: java.lang.NullPointerException
> 	at
> org.apache.cxf.binding.soap.SoapTransportFactory.getDestination(SoapTranspo
> rtFactory.java:134) at
> org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:93) at
> org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:72)
> 	at
> org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:158
> ) at
> org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.j
> ava:202) at
> org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:433) at
> org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:322) ... 45
> more
> 
> On Wed, Nov 23, 2011 at 4:47 PM, Daniel Kulp <dk...@apache.org> wrote:
> > On Wednesday, November 23, 2011 12:58:17 PM Alex Shneyderman wrote:
> >> Hello,
> >> 
> >> I have a requirement where I need to configure a client proxy that
> >> does not actually make http request to the endpoint. We use
> >> org.apache.cxf.jaxws.JaxWsProxyFactoryBean to instantiate client
> >> proxies. Is there a way to instruct the factory to construct proxy in
> >> a way where calls to the remote end point are diverted to the calls to
> >> the local object instance?
> >> 
> >> I want to preserve all the logging that we have configured on this
> >> proxy (we log request/response soap messages) - not sure if this is
> >> even possible.
> >> 
> >> Any hints/solutions are greatly appreciated.
> > 
> > We have a "local" transport which probably would be usable for you.  
> > You can create a server (JaxWsServerFactoryBean) that uses a
> > "local:/Foo" address and then in the JaxWsProxyFactoryBean use the same
> > address.    That would pipe it through to the local object,but still do
> > all the serialization and logging and such.
> > 
> > Dan
> > 
> >> Cheers,
> >> Alex.
> > 
> > --
> > Daniel Kulp
> > dkulp@apache.org - http://dankulp.com/blog
> > Talend Community Coder - http://coders.talend.com
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Re: Client stub that does not call the actual end point.

Posted by Alex Shneyderman <a....@gmail.com>.
Hi, Daniel!

Is there any other configuration that needs to be done for this?

I configured this:

    <bean id="mock.clientFactory"
class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
		<property name="serviceClass" value="blah.TroubleTicket" />
		<property name="address" value="local://TroubleTicketMock" />
    </bean>

    <bean id="blah.TroubleTicketMock"
          class="blah.p.TroubleTicketMock" />

    <jaxws:endpoint id="mock.server"
		implementor="#blah.TroubleTicketMock"
		address="local://TroubleTicketMock">
	</jaxws:endpoint>

on initialization call I get exception:

org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'mock.serverr': Invocation of init method
failed; nested exception is javax.xml.ws.WebServiceException:
java.lang.NullPointerException
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
	at org.springframework.test.AbstractSingleSpringContextTests.createApplicationContext(AbstractSingleSpringContextTests.java:213)
	at org.springframework.test.AbstractSingleSpringContextTests.loadContextLocations(AbstractSingleSpringContextTests.java:189)
	at org.springframework.test.AbstractSingleSpringContextTests.loadContext(AbstractSingleSpringContextTests.java:169)
	at org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:140)
	at org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:98)
	at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
	at com.intellij.junit3.JUnit3IdeaTestRunner.doRun(JUnit3IdeaTestRunner.java:139)
	at com.intellij.junit3.JUnit3IdeaTestRunner.startRunnerWithArgs(JUnit3IdeaTestRunner.java:52)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:199)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: javax.xml.ws.WebServiceException: java.lang.NullPointerException
	at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:350)
	at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:239)
	at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:509)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1414)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1375)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
	... 36 more
Caused by: java.lang.NullPointerException
	at org.apache.cxf.binding.soap.SoapTransportFactory.getDestination(SoapTransportFactory.java:134)
	at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:93)
	at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:72)
	at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:158)
	at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:202)
	at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:433)
	at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:322)
	... 45 more

On Wed, Nov 23, 2011 at 4:47 PM, Daniel Kulp <dk...@apache.org> wrote:
> On Wednesday, November 23, 2011 12:58:17 PM Alex Shneyderman wrote:
>> Hello,
>>
>> I have a requirement where I need to configure a client proxy that
>> does not actually make http request to the endpoint. We use
>> org.apache.cxf.jaxws.JaxWsProxyFactoryBean to instantiate client
>> proxies. Is there a way to instruct the factory to construct proxy in
>> a way where calls to the remote end point are diverted to the calls to
>> the local object instance?
>>
>> I want to preserve all the logging that we have configured on this
>> proxy (we log request/response soap messages) - not sure if this is
>> even possible.
>>
>> Any hints/solutions are greatly appreciated.
>
> We have a "local" transport which probably would be usable for you.   You can
> create a server (JaxWsServerFactoryBean) that uses a "local:/Foo" address and
> then in the JaxWsProxyFactoryBean use the same address.    That would pipe it
> through to the local object,but still do all the serialization and logging and
> such.
>
> Dan
>
>
>>
>> Cheers,
>> Alex.
> --
> Daniel Kulp
> dkulp@apache.org - http://dankulp.com/blog
> Talend Community Coder - http://coders.talend.com
>

Re: Client stub that does not call the actual end point.

Posted by Daniel Kulp <dk...@apache.org>.
On Wednesday, November 23, 2011 12:58:17 PM Alex Shneyderman wrote:
> Hello,
> 
> I have a requirement where I need to configure a client proxy that
> does not actually make http request to the endpoint. We use
> org.apache.cxf.jaxws.JaxWsProxyFactoryBean to instantiate client
> proxies. Is there a way to instruct the factory to construct proxy in
> a way where calls to the remote end point are diverted to the calls to
> the local object instance?
> 
> I want to preserve all the logging that we have configured on this
> proxy (we log request/response soap messages) - not sure if this is
> even possible.
> 
> Any hints/solutions are greatly appreciated.

We have a "local" transport which probably would be usable for you.   You can 
create a server (JaxWsServerFactoryBean) that uses a "local:/Foo" address and 
then in the JaxWsProxyFactoryBean use the same address.    That would pipe it 
through to the local object,but still do all the serialization and logging and 
such.

Dan


> 
> Cheers,
> Alex.
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com