...
Code Block |
---|
|
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/bindings/soap
http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<jaxws:endpoint
id="helloWorld"
implementor="demo.spring.HelloWorldImpl"
address="http://localhost/HelloWorld">
<jaxws:inInterceptors>
<bean class="com.acme.SomeInterceptor"/>
<ref bean="anotherInterceptor"/>
</jaxws:inInterceptor>
<jaxws:properties>
<entry key="mtom-enabled" value="true"/>
</jaxws:properties>
</jaxws:endpoint>
<bean id="anotherInterceptor" class="com.acme.SomeInterceptor"/>
<jaxws:endpoint id="simpleWithBinding"
implementor="#greeter"
address="http://localhost:8080/simpleWithAddress">
<jaxws:binding>
<soap:soapBinding mtomEnabled="true" version="1.2"/>
</jaxws:binding>
</jaxws:endpoint>
<jaxws:endpoint id="inlineInvoker"
address="http://localhost:8080/simpleWithAddress">
<jaxws:implementor>
<bean class="org.apache.hello_world_soap_http.GreeterImpl"/>
</jaxws:implementor>
<jaxws:invoker>
<bean class="org.apache.cxf.jaxws.spring.NullInvoker"/>
</jaxws:invoker>
</jaxws:endpoint>
</beans>
|
...
Code Block |
---|
|
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http:// http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<jaxws:client id="helloClient"
serviceClass="demo.spring.HelloWorld"
address="http://localhost:9002/HelloWorld" />
</beans>
|
...
Code Block |
---|
|
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://
http://cxf.apache.org/schemas/jaxws.xsd">
<!-- Interceptors extend e.g.
org.apache.cxf.phase.AbstractPhaseInterceptor -->
<bean id="anotherInterceptor" class="..." />
<!-- Handlers implement e.g. javax.xml.ws.handler.soap.SOAPHandler -->
<bean id="jaxwsHandler" class="..." />
<!-- The SOAP client bean -->
<jaxws:client id="helloClient"
serviceClass="demo.spring.HelloWorld"
address="http://localhost:9002/HelloWorld">
<jaxws:inInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
<ref bean="anotherInterceptor"/>
</jaxws:inInterceptor>
<jaxws:handlers>
<ref bean="jaxwsHandler" />
</jaxws:handlers>
<jaxws:properties>
<entry key="mtom-enabled" value="true"/>
</jaxws:properties>
</jaxws:client>
</beans>
|
...
Code Block |
---|
|
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<bean id="proxyFactory"
class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="demo.spring.HelloWorld"/>
<property name="address" value="http://localhost:9002/HelloWorld"/>
</bean>
<bean id="client" class="demo.spring.HelloWorld"
factory-bean="proxyFactory" factory-method="create"/>
</beans>
|
...
Code Block |
---|
|
include org.springframework.context.support.ClassPathXmlApplicationContext;
public final class HelloWorldClient {
private HelloWorldClient() { }
public static void main(String args[]) throws Exception {
ClassPathXmlApplicationContext context
= new ClassPathXmlApplicationContext(
new String[]{"my/path/to/client-beans.xml"});
HelloWorld client = (HelloWorld)context.getBean("client");
String response = client.sayHi("Dan");
System.out.println("Response: " + response);
System.exit(0);
}
}
|
...
Code Block |
---|
|
javax.xml.ws.Endpoint jaxwsEndpoint = javax.xml.ws.Endpoint.publish(
"http://localhost:9020/SoapContext/GreeterPort", new GreeterImpl());
org.apache.cxf.jaxws.EndpointImpl jaxwsEndpointImpl =
(org.apache.cxf.jaxws.EndpointImpl)jaxwsEndpoint;
org.apache.cxf.endpoint.Server server = jaxwsEndpointImpl.getServer();
org.apache.cxf.endpoint.Endpoint cxfEndpoint = server.getEndpoint();
cxfEndpoint.getOutInterceptors().add(...);
org.apache.cxf.service.Service cxfService = cxfEndpoint.getService();
cxfService.getOutInterceptors().add(...);
|
...
CXF provides <jaxws:server>, <jaxws:client> to configure the server/client side endpoint. Here are some exmplesexamples:
Code Block |
---|
|
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xsi:schemaLocation="
http: http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/bindings/soap
http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<jaxws:server id="inlineImplementor" address="http://localhost:8080/simpleWithAddress">
<jaxws:serviceBean>
<bean class="org.apache.hello_world_soap_http.GreeterImpl"/>
</jaxws:serviceBean>
</jaxws:server>
<jaxws:server id="bookServer" serviceClass=
serviceClass="org.apache.cxf.anonymous_complex_typemytype.AnonymousComplexTypeImpl"
address="http://localhost:8080/act"
bus="cxf">
<jaxws:invoker>
<bean class="org.apache.cxf.service.invoker.BeanInvoker">
<constructor-arg>
<bean class="org.apache.cxf.anonymous_complex_typemytype.AnonymousComplexTypeImpl"/>
</constructor-arg>
</bean>
</jaxws:invoker>
<jaxws:dataBinding>
<bean class="org.apache.cxf.jaxb.JAXBDataBinding">
<property name="namespaceMap">
<map>
<entry>
<key><value>http <key>
<value>http://cxf.apache.org/anonymousanon_complex_type/</value><value>
</key>
<value>BeepBeep</value>
</entry>
</map>
</property>
</bean>
</jaxws:dataBinding>
</jaxws:server>
<jaxws:client id="bookClient"
serviceClass="org.apache.cxf.anonymous_complex_typemytype.AnonymousComplexType"
address="http://localhost:8080/act"/>
</beans>
|
...