You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Dhiego Abrantes de Oliveira Martins <dh...@dhiegoabrantes.com> on 2013/02/23 07:58:19 UTC

About accessing CXF Webservice

Hi,

I'm trying to access my cxf webservice running in felix container.

Code to try access:

JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();

factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
factory.setServiceClass(AdderService.class);
factory.setAddress("http://localhost:9090/adder");
AdderService client = (AdderService) factory.create();

*String a = client.add();*
System.out.println(a);

So...

When the bold line is executed, the service is accessed and executed (the
service writes a word in console when called) successfuly. However, the
value returned is null and I dont understand why...

The following message is written in console when the bold line above is
executed:

Fev 23, 2013 3:50:44 AM
org.springframework.context.support.AbstractApplicationContext
prepareRefresh
INFO: Refreshing org.apache.cxf.bus.spring.BusApplicationContext@6d36d73:
display name [org.apache.cxf.bus.spring.BusApplicationContext@6d36d73];
startup date [Sat Feb 23 03:50:44 BRT 2013]; root of context hierarchy
Fev 23, 2013 3:50:44 AM org.apache.cxf.bus.spring.BusApplicationContext
getConfigResources
INFO: No cxf.xml configuration file detected, relying on defaults.
Fev 23, 2013 3:50:44 AM
org.springframework.context.support.AbstractApplicationContext
obtainFreshBeanFactory
INFO: Bean factory for application context
[org.apache.cxf.bus.spring.BusApplicationContext@6d36d73]:
org.springframework.beans.factory.support.DefaultListableBeanFactory@7c9aff86
Fev 23, 2013 3:50:44 AM
org.springframework.beans.factory.support.DefaultListableBeanFactory
preInstantiateSingletons
INFO: Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@7c9aff86:
defining beans
[cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.jaxws.context.WebServiceContextResourceResolver,org.apache.cxf.jaxws.context.WebServiceContextImpl,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.binding.xml.XMLBindingFactory,org.apache.cxf.ws.addressing.policy.AddressingAssertionBuilder,org.apache.cxf.ws.addressing.policy.AddressingPolicyInterceptorProvider,org.apache.cxf.ws.addressing.policy.UsingAddressingAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory];
root of factory hierarchy
Fev 23, 2013 3:50:45 AM
org.apache.cxf.service.factory.ReflectionServiceFactoryBean
buildServiceFromClass
INFO: Creating Service {
http://adder.remote.ipojo.felix.apache.org/}AdderServiceService from class
org.apache.felix.ipojo.remote.adder.AdderService
Fev 23, 2013 3:50:47 AM
org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
INFO: Outbound Message
---------------------------
ID: 1
Address: http://localhost:9090/adder
Encoding: UTF-8
Content-Type: text/xml
Headers: {SOAPAction=[""], Accept=[*/*]}
Payload: <soap:Envelope xmlns:soap="
http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:add xmlns:ns2="
http://adder.remote.ipojo.felix.apache.org/"/></soap:Body></soap:Envelope>
--------------------------------------
Fev 23, 2013 3:50:47 AM org.apache.cxf.interceptor.LoggingInInterceptor
logging
INFO: Inbound Message
----------------------------
ID: 1
Encoding: UTF-8
Content-Type: text/xml;charset=UTF-8
Headers: {content-type=[text/xml;charset=UTF-8], Content-Length=[231],
Server=[Jetty(7.x.y-SNAPSHOT)]}
Payload: <soap:Envelope xmlns:soap="
http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:addResponse
xmlns:ns1="http://adder.remote.ipojo.felix.apache.org/">*
<ns1:return>dhiego</ns1:return>*
</ns1:addResponse></soap:Body></soap:Envelope>
--------------------------------------

The bold part is the return of my service, the String "dhiego".

Anyone can help me?

Best regards!
__
*Dhiego** **Abrantes*

Re: About accessing CXF Webservice

Posted by Dhiego Abrantes de Oliveira Martins <dh...@dhiegoabrantes.com>.
Daniel,

As follow:

@Component(propagation=true)
@Provides
public class AdderServiceImpl implements AdderService {
            public String add() {
                     System.out.println("Called!");
                     return "dhiego";
           }
 }

@WebService
public interface AdderService {
         String add();
}

I'm using iPOJO to manage this service.

Best regards!
__
*Dhiego** **Abrantes*


2013/2/25 Daniel Kulp <dk...@apache.org>

>
> On Feb 23, 2013, at 1:58 AM, Dhiego Abrantes de Oliveira Martins <
> dhiego@dhiegoabrantes.com> wrote:
>
> > Hi,
> >
> > I'm trying to access my cxf webservice running in felix container.
> >
> > Code to try access:
> >
> > JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> >
> > factory.getInInterceptors().add(new LoggingInInterceptor());
> > factory.getOutInterceptors().add(new LoggingOutInterceptor());
> > factory.setServiceClass(AdderService.class);
> > factory.setAddress("http://localhost:9090/adder");
> > AdderService client = (AdderService) factory.create();
>
> The response message is sending the "return" element as a fully namespace
> qualified element.  That's not the default for JAX-WS.   Can I see your
> @WebResult annotation on the add method?   It likely needs to have the
> targetNamespace attribute added to it.
>
> Dan
>
>
> >
> > *String a = client.add();*
> > System.out.println(a);
> >
> > So...
> >
> > When the bold line is executed, the service is accessed and executed (the
> > service writes a word in console when called) successfuly. However, the
> > value returned is null and I dont understand why...
> >
> > The following message is written in console when the bold line above is
> > executed:
> >
> > Fev 23, 2013 3:50:44 AM
> > org.springframework.context.support.AbstractApplicationContext
> > prepareRefresh
> > INFO: Refreshing org.apache.cxf.bus.spring.BusApplicationContext@6d36d73
> :
> > display name [org.apache.cxf.bus.spring.BusApplicationContext@6d36d73];
> > startup date [Sat Feb 23 03:50:44 BRT 2013]; root of context hierarchy
> > Fev 23, 2013 3:50:44 AM org.apache.cxf.bus.spring.BusApplicationContext
> > getConfigResources
> > INFO: No cxf.xml configuration file detected, relying on defaults.
> > Fev 23, 2013 3:50:44 AM
> > org.springframework.context.support.AbstractApplicationContext
> > obtainFreshBeanFactory
> > INFO: Bean factory for application context
> > [org.apache.cxf.bus.spring.BusApplicationContext@6d36d73]:
> >
> org.springframework.beans.factory.support.DefaultListableBeanFactory@7c9aff86
> > Fev 23, 2013 3:50:44 AM
> > org.springframework.beans.factory.support.DefaultListableBeanFactory
> > preInstantiateSingletons
> > INFO: Pre-instantiating singletons in
> >
> org.springframework.beans.factory.support.DefaultListableBeanFactory@7c9aff86
> :
> > defining beans
> >
> [cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.jaxws.context.WebServiceContextResourceResolver,org.apache.cxf.jaxws.context.WebServiceContextImpl,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.binding.xml.XMLBindingFactory,org.apache.cxf.ws.addressing.policy.AddressingAssertionBuilder,org.apache.cxf.ws.addressing.policy.AddressingPolicyInterceptorProvider,org.apache.cxf.ws.addressing.policy.UsingAddressingAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory];
> > root of factory hierarchy
> > Fev 23, 2013 3:50:45 AM
> > org.apache.cxf.service.factory.ReflectionServiceFactoryBean
> > buildServiceFromClass
> > INFO: Creating Service {
> > http://adder.remote.ipojo.felix.apache.org/}AdderServiceService from
> class
> > org.apache.felix.ipojo.remote.adder.AdderService
> > Fev 23, 2013 3:50:47 AM
> > org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
> > INFO: Outbound Message
> > ---------------------------
> > ID: 1
> > Address: http://localhost:9090/adder
> > Encoding: UTF-8
> > Content-Type: text/xml
> > Headers: {SOAPAction=[""], Accept=[*/*]}
> > Payload: <soap:Envelope xmlns:soap="
> > http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:add
> xmlns:ns2="
> > http://adder.remote.ipojo.felix.apache.org/
> "/></soap:Body></soap:Envelope>
> > --------------------------------------
> > Fev 23, 2013 3:50:47 AM org.apache.cxf.interceptor.LoggingInInterceptor
> > logging
> > INFO: Inbound Message
> > ----------------------------
> > ID: 1
> > Encoding: UTF-8
> > Content-Type: text/xml;charset=UTF-8
> > Headers: {content-type=[text/xml;charset=UTF-8], Content-Length=[231],
> > Server=[Jetty(7.x.y-SNAPSHOT)]}
> > Payload: <soap:Envelope xmlns:soap="
> > http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:addResponse
> > xmlns:ns1="http://adder.remote.ipojo.felix.apache.org/">*
> > <ns1:return>dhiego</ns1:return>*
> > </ns1:addResponse></soap:Body></soap:Envelope>
> > --------------------------------------
> >
> > The bold part is the return of my service, the String "dhiego".
> >
> > Anyone can help me?
> >
> > Best regards!
> > __
> > *Dhiego** **Abrantes*
>
> --
> Daniel Kulp
> dkulp@apache.org - http://dankulp.com/blog
> Talend Community Coder - http://coders.talend.com
>
>

Re: About accessing CXF Webservice

Posted by Daniel Kulp <dk...@apache.org>.
On Feb 23, 2013, at 1:58 AM, Dhiego Abrantes de Oliveira Martins <dh...@dhiegoabrantes.com> wrote:

> Hi,
> 
> I'm trying to access my cxf webservice running in felix container.
> 
> Code to try access:
> 
> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> 
> factory.getInInterceptors().add(new LoggingInInterceptor());
> factory.getOutInterceptors().add(new LoggingOutInterceptor());
> factory.setServiceClass(AdderService.class);
> factory.setAddress("http://localhost:9090/adder");
> AdderService client = (AdderService) factory.create();

The response message is sending the "return" element as a fully namespace qualified element.  That's not the default for JAX-WS.   Can I see your @WebResult annotation on the add method?   It likely needs to have the targetNamespace attribute added to it.

Dan


> 
> *String a = client.add();*
> System.out.println(a);
> 
> So...
> 
> When the bold line is executed, the service is accessed and executed (the
> service writes a word in console when called) successfuly. However, the
> value returned is null and I dont understand why...
> 
> The following message is written in console when the bold line above is
> executed:
> 
> Fev 23, 2013 3:50:44 AM
> org.springframework.context.support.AbstractApplicationContext
> prepareRefresh
> INFO: Refreshing org.apache.cxf.bus.spring.BusApplicationContext@6d36d73:
> display name [org.apache.cxf.bus.spring.BusApplicationContext@6d36d73];
> startup date [Sat Feb 23 03:50:44 BRT 2013]; root of context hierarchy
> Fev 23, 2013 3:50:44 AM org.apache.cxf.bus.spring.BusApplicationContext
> getConfigResources
> INFO: No cxf.xml configuration file detected, relying on defaults.
> Fev 23, 2013 3:50:44 AM
> org.springframework.context.support.AbstractApplicationContext
> obtainFreshBeanFactory
> INFO: Bean factory for application context
> [org.apache.cxf.bus.spring.BusApplicationContext@6d36d73]:
> org.springframework.beans.factory.support.DefaultListableBeanFactory@7c9aff86
> Fev 23, 2013 3:50:44 AM
> org.springframework.beans.factory.support.DefaultListableBeanFactory
> preInstantiateSingletons
> INFO: Pre-instantiating singletons in
> org.springframework.beans.factory.support.DefaultListableBeanFactory@7c9aff86:
> defining beans
> [cxf,org.apache.cxf.bus.spring.BusApplicationListener,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.jaxws.context.WebServiceContextResourceResolver,org.apache.cxf.jaxws.context.WebServiceContextImpl,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.binding.xml.XMLBindingFactory,org.apache.cxf.ws.addressing.policy.AddressingAssertionBuilder,org.apache.cxf.ws.addressing.policy.AddressingPolicyInterceptorProvider,org.apache.cxf.ws.addressing.policy.UsingAddressingAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory];
> root of factory hierarchy
> Fev 23, 2013 3:50:45 AM
> org.apache.cxf.service.factory.ReflectionServiceFactoryBean
> buildServiceFromClass
> INFO: Creating Service {
> http://adder.remote.ipojo.felix.apache.org/}AdderServiceService from class
> org.apache.felix.ipojo.remote.adder.AdderService
> Fev 23, 2013 3:50:47 AM
> org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
> INFO: Outbound Message
> ---------------------------
> ID: 1
> Address: http://localhost:9090/adder
> Encoding: UTF-8
> Content-Type: text/xml
> Headers: {SOAPAction=[""], Accept=[*/*]}
> Payload: <soap:Envelope xmlns:soap="
> http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:add xmlns:ns2="
> http://adder.remote.ipojo.felix.apache.org/"/></soap:Body></soap:Envelope>
> --------------------------------------
> Fev 23, 2013 3:50:47 AM org.apache.cxf.interceptor.LoggingInInterceptor
> logging
> INFO: Inbound Message
> ----------------------------
> ID: 1
> Encoding: UTF-8
> Content-Type: text/xml;charset=UTF-8
> Headers: {content-type=[text/xml;charset=UTF-8], Content-Length=[231],
> Server=[Jetty(7.x.y-SNAPSHOT)]}
> Payload: <soap:Envelope xmlns:soap="
> http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:addResponse
> xmlns:ns1="http://adder.remote.ipojo.felix.apache.org/">*
> <ns1:return>dhiego</ns1:return>*
> </ns1:addResponse></soap:Body></soap:Envelope>
> --------------------------------------
> 
> The bold part is the return of my service, the String "dhiego".
> 
> Anyone can help me?
> 
> Best regards!
> __
> *Dhiego** **Abrantes*

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