Spring configuration

  • The spring configuration application-context.xml contains the bean definitions for the web service, end points as well as the consumers
  • The spring schema extensions for cxf are defined by
    	<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" />
    
  • The web service implementations are defined by
    	<bean id="hello" class="com.yosanai.tutorial.ws.hellowebservice.HelloWorldImpl" />
    	<bean id="fileMgmt"
    		class="com.yosanai.tutorial.ws.hellowebservice.FileManagementImpl" />
    
  • The cxf specific web service end points are defined by
    	<jaxws:endpoint id="helloWorld" implementor="#hello"
    		address="/HelloWorld" />
    
    	<jaxws:endpoint id="fileManagement" implementor="#fileMgmt"
    		address="/FileManagement">
    		<jaxws:properties>
    			<entry key="mtom-enabled" value="true" />
    		</jaxws:properties>
    	</jaxws:endpoint>
    
  • CXF also creates dynamic consumers for the defined web services using spring factory beans, this way we don't have to write custom code :-)
    	<bean id="helloClient" class="com.yosanai.tutorial.ws.hellowebservice.HelloWorld"
    		factory-bean="helloClientFactory" factory-method="create" />
    
    	<bean id="helloClientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
    		<property name="serviceClass"
    			value="com.yosanai.tutorial.ws.hellowebservice.HelloWorld" />
    		<property name="address" value="http://localhost/HelloWorld" />
    	</bean>
    
    	<bean id="fileClient" class="com.yosanai.tutorial.ws.hellowebservice.FileManagement"
    		factory-bean="fileClientFactory" factory-method="create" />
    
    	<bean id="fileClientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
    		<property name="serviceClass"
    			value="com.yosanai.tutorial.ws.hellowebservice.FileManagement" />
    		<property name="address" value="http://localhost/FileManagement" />
    	</bean>
    </beans>
    
  • Here the helloClient bean is created using helloClientFactory based on com.yosanai.tutorial.ws.hellowebservice.HelloWorld and pointing to the end point at http://localhost/HelloWorld and the same is done for fileClient as well

Who's online

There are currently 0 users and 1 guest online.

Who's new

  • Saravana Peruma...