Announcement Announcement Module
No announcement yet.
Correct approach for configuring a WS wich is client and server at the same time. Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Correct approach for configuring a WS wich is client and server at the same time.

    Hello everybody.
    I'm a newbie in both spring and ws, and so far, I like what I see in spring quite a lot.

    I've been following the reference documentation, some tutorials, books, etc., and I managed to set up some services, and to make some clients for them.

    I am currently in the situation where one ws (lets call it wsA) has to consume another ws (wsB), for which I already have a spring-ws client working . However, I am not able to configure the client inside wsA. The probable cause is that wsA is a rpc-style service that uses CXF.

    This is the original wsA app-context:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns=""
    	xmlns:xsi="" xmlns:context=""
    	xmlns:jee="" xmlns:jaxws=""
    	default-dependency-check="none" default-lazy-init="false">
    	<!-- Load the needed resources that are present in the cxf* jars -->
    	<import resource="classpath:META-INF/cxf/cxf.xml" />
    	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
    	<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
    	<!-- Hook up the web service -->
    	<jaxws:endpoint id="store"  implementor="store.StoreService" 
    ..and web.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns=""
    	<display-name>Tienda de JP</display-name>
    This is the wsB client app-context:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="" xmlns:xsi=""
    	<bean id="loggingClient" class="">
    		<property name="defaultUri" value="http://localhost:8080/logging/services/logging"/>
    		<property name="marshaller" ref="marshaller"/>
    		<property name="unmarshaller" ref="marshaller"/>
         <bean class="">
             <constructor-arg ref="marshaller" />
         <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
    	<property name="contextPath" value=""/>
    Both services and the client are working independently. However, when trying to insert the client into wsA app-context (as simple as copying the definitions of the loggingClient, GenericMarshallingMethodEndpointAdapter, and marshaller in the app-context, and injecting loggingClient into the store endpoint) I get a:

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.cxf.resource.ResourceManager' defined in class path resource [META-INF/cxf/cxf.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [] for bean with name '' defined in class path resource [appContext.xml]; nested exception is java.lang.ClassNotFoundException:
    I believe is not a dependency issue, as I use maven for both projects and have the same dependencies.
    If I remove the GenericMarshallingMethodEndpointAdapter bean, I get an InvocationTargetException (caused by a NullPointerException) at the createMarshaller() method of AbstractJaxbMarshaller class (jaxbContext is null).

    I would really appreciate some help with this, as there are no examples or documentation on merging clients within endpoints. I thought on splitting the configuration files, but I don't know how to inject the client bean into the endpoint if they were defined in two different app-contexts.

    All help will be very much appreciated!!.

  • #2
    I had to figure this out myself.

    The correct way to go is to:
    A) Configure the jaxws:endpoint's "implementator" property with a reference to the service bean declaration.
    B) Inject the client in the bean's declaration, not in the endpoint declaration.

    The resulting app-context is:
    	<!-- Hook up the web service --> 
    	<jaxws:endpoint id="tienda" address="/tienda">
    			<ref bean="retailerService"/>
    	<bean id="retailerService" class="service.RetailerService">
    		<property name="logStub" ref="loggingClient"/>
             <bean id="loggingClient" class="logging.LoggingClient">
    		<property name="defaultUri" value="http://localhost:8888/logging/services/logging" />
    		<property name="marshaller" ref="loggingMarshaller"/>
      		<property name="unmarshaller" ref="loggingMarshaller"/>
    	 <bean id="loggingMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
    		<property name="contextPath" value="types.logging"/>