Skip to content


Context.xml

<?xml version = "1.0" encoding = "UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://cxf.apache.org/core"
	xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:jaxws="http://cxf.apache.org/jaxws"
	xmlns:wsp="http://www.w3.org/2006/07/ws-policy" xmlns:p="http://cxf.apache.org/policy"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="
 		http://www.springframework.org/schema/beans
 		http://www.springframework.org/schema/beans/spring-beans.xsd
 		http://cxf.apache.org/jaxrs
 		http://cxf.apache.org/schemas/jaxrs.xsd
 		http://cxf.apache.org/jaxws
 		http://cxf.apache.org/schemas/jaxws.xsd
 		http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
 		http://www.w3.org/2006/07/ws-policy
 		http://www.w3.org/2006/11/ws-policy.xsd
 		http://cxf.apache.org/policy
 		http://cxf.apache.org/schemas/policy.xsd
 		http://www.springframework.org/schema/context
 		http://www.springframework.org/schema/context/spring-context-2.5.xsd">
	<!-- Load CXF modules from cxf.jar -->
	<import resource="classpath:META-INF/cxf/cxf.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-xml.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
	<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-ws-security.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-policy.xml" />

	<bean id="userWebService" class="com.company.webservice.impl.UserServiceImpl">
		<property name="userManagementService" ref="userManagementService" />
	</bean>
	<!-- Security -->
	<bean id="wsAuthenticationInterceptor" class="com.company.auth.service.CompanyWSS4JInInterceptor">
		<constructor-arg index="0">
			<map>
				<entry key="action" value="UsernameToken" />
				<entry key="passwordType" value="PasswordText" />
				<entry key="passwordCallbackRef">
					<ref bean="jaxwsPasswordCallback" />
				</entry>
			</map>
		</constructor-arg>
		<property name="authenticationProvider" ref="customAuthenticationProvider" />
	</bean>

	<bean id="jaxwsPasswordCallback" class="com.company.auth.service.ServerPasswordCallback">
	</bean>

	<bean id="securityInterceptor"
		class="com.company.auth.service.BasicAuthAuthorizationInterceptor">
		<property name="authenticationProvider" ref="customAuthenticationProvider" />
	</bean>
	<!-- Enable message logging using the CXF logging feature -->
	<cxf:bus>
		<cxf:features>
			<cxf:logging />
		</cxf:features>
    </cxf:bus>


	<!-- Aegis data binding -->
	<bean id="aegisBean" class="org.apache.cxf.aegis.databinding.AegisDatabinding"
		scope="prototype">
		<property name="configuration">
			<bean class="org.apache.cxf.aegis.type.TypeCreationOptions">
				<property name="defaultMinOccurs" value="1" />
				<property name="defaultNillable" value="false" />
			</bean>
		</property>
	</bean>
	<bean id="jaxws-and-aegis-service-factory" class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"
		scope="prototype">
		<property name="dataBinding" ref="aegisBean" />
		<property name="serviceConfigurations">
			<list>
				<bean class="org.apache.cxf.jaxws.support.JaxWsServiceConfiguration" />
				<bean class="org.apache.cxf.aegis.databinding.AegisServiceConfiguration" />
				<bean class="org.apache.cxf.service.factory.DefaultServiceConfiguration" />
			</list>
		</property>
	</bean>

	<bean id="aegisProvider" class="org.apache.cxf.jaxrs.provider.AegisElementProvider" />
	<!-- JAX-WS SOAP -->
	<!-- Service endpoint -->
	<jaxws:endpoint id="UserService-v1"
		implementor="#userWebService" 
		address="/v1/soap/user">
		<jaxws:serviceFactory>
			<ref bean="jaxws-and-aegis-service-factory" />
		</jaxws:serviceFactory>
		<jaxws:inInterceptors>
			<ref bean="wsAuthenticationInterceptor" />
		</jaxws:inInterceptors>
	</jaxws:endpoint>

	<!-- REST -->
	<jaxrs:server id="rest" address="/v1/rest">
		<jaxrs:serviceBeans>
			<ref bean="userWebService" />
		</jaxrs:serviceBeans>
		<jaxrs:providers>
			<ref bean="aegisProvider" />
		</jaxrs:providers>
		<jaxrs:inInterceptors>
			<ref bean="securityInterceptor" />
		</jaxrs:inInterceptors>

	</jaxrs:server>
</beans>

<?xml version = “1.0” encoding = “UTF-8″?>
<beans xmlns=”http://www.springframework.org/schema/beans”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:cxf=”http://cxf.apache.org/core”
xmlns:jaxrs=”http://cxf.apache.org/jaxrs” xmlns:jaxws=”http://cxf.apache.org/jaxws”
xmlns:wsp=”http://www.w3.org/2006/07/ws-policy” xmlns:p=”http://cxf.apache.org/policy”
xmlns:context=”http://www.springframework.org/schema/context”
xsi:schemaLocation=”
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://www.w3.org/2006/07/ws-policy
http://www.w3.org/2006/11/ws-policy.xsd
http://cxf.apache.org/policy
http://cxf.apache.org/schemas/policy.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd”>
<!–
default-autowire=”byName”
–>
<!– Load CXF modules from cxf.jar –>
<import resource=”classpath:META-INF/cxf/cxf.xml” />
<import resource=”classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml” />
<import resource=”classpath:META-INF/cxf/cxf-extension-http-binding.xml” />
<import resource=”classpath:META-INF/cxf/cxf-extension-xml.xml” />
<import resource=”classpath:META-INF/cxf/cxf-extension-soap.xml” />
<import resource=”classpath:META-INF/cxf/cxf-servlet.xml” />
<import resource=”classpath:META-INF/cxf/cxf-extension-ws-security.xml” />
<import resource=”classpath:META-INF/cxf/cxf-extension-policy.xml” />

<bean id=”userWebService” class=”com.company.webservice.impl.UserServiceImpl”>
<property name=”userManagementService” ref=”userManagementService” />
</bean>
<!– Security –>
<bean id=”wsAuthenticationInterceptor” class=”com.company.auth.service.CompanyWSS4JInInterceptor”>
<constructor-arg index=”0″>
<map>
<entry key=”action” value=”UsernameToken” />
<entry key=”passwordType” value=”PasswordText” />
<entry key=”passwordCallbackRef”>
<ref bean=”jaxwsPasswordCallback” />
</entry>
</map>
</constructor-arg>
<property name=”authenticationProvider” ref=”customAuthenticationProvider” />
</bean>

<bean id=”jaxwsPasswordCallback” class=”com.company.auth.service.ServerPasswordCallback”>
</bean>

<bean id=”securityInterceptor”
class=”com.company.auth.service.BasicAuthAuthorizationInterceptor”>
<property name=”authenticationProvider” ref=”customAuthenticationProvider” />
</bean>
<!– Enable message logging using the CXF logging feature –>
<cxf:bus>
<cxf:features>
<cxf:logging />
</cxf:features>
</cxf:bus>

<!– Aegis data binding –>
<bean id=”aegisBean” class=”org.apache.cxf.aegis.databinding.AegisDatabinding”
scope=”prototype”>
<property name=”configuration”>
<bean class=”org.apache.cxf.aegis.type.TypeCreationOptions”>
<property name=”defaultMinOccurs” value=”1″ />
<property name=”defaultNillable” value=”false” />
</bean>
</property>
</bean>
<bean id=”jaxws-and-aegis-service-factory” class=”org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean”
scope=”prototype”>
<property name=”dataBinding” ref=”aegisBean” />
<property name=”serviceConfigurations”>
<list>
<bean class=”org.apache.cxf.jaxws.support.JaxWsServiceConfiguration” />
<bean class=”org.apache.cxf.aegis.databinding.AegisServiceConfiguration” />
<bean class=”org.apache.cxf.service.factory.DefaultServiceConfiguration” />
</list>
</property>
</bean>

<bean id=”aegisProvider” class=”org.apache.cxf.jaxrs.provider.AegisElementProvider” />
<!– JAX-WS SOAP –>
<!– Service endpoint –>
<jaxws:endpoint id=”UserService-v1″
implementor=”#userWebService”
address=”/v1/soap/user”>
<jaxws:serviceFactory>
<ref bean=”jaxws-and-aegis-service-factory” />
</jaxws:serviceFactory>
<jaxws:inInterceptors>
<ref bean=”wsAuthenticationInterceptor” />
</jaxws:inInterceptors>
</jaxws:endpoint>

<!– REST –>
<jaxrs:server id=”rest” address=”/v1/rest”>
<jaxrs:serviceBeans>
<ref bean=”userWebService” />
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean=”aegisProvider” />
</jaxrs:providers>
<jaxrs:inInterceptors>
<ref bean=”securityInterceptor” />
</jaxrs:inInterceptors>

</jaxrs:server>
</beans>


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

You must be logged in to post a comment.