...
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"> <jaxws:endpoint id="classImpl" implementor="org.apache.cxf.jaxws.service.Hello" endpointName="e:HelloEndpointCustomized" serviceName="s:HelloServiceCustomized" address="http://localhost:8080/test" xmlns:e="http://service.jaxws.cxf.apache.org/endpoint" xmlns:s="http://service.jaxws.cxf.apache.org/service"/> </beans> |
Be sure to include the JAX-WS schemaLocation
attribute specified on the root beans element. This allows CXF to validate the file and is required. Also note the namespace declarations at the end of the <jaxws:endpoint/> tag--these are required because the combined "{namespace}localName" syntax is presently not supported for this tag's attribute values.
The jaxws:endpoint
element supports many additional attributes:
Name | Value |
---|---|
portName endpointName | The port endpoint name this service is implementing, it maps to the wsdl:port@name. In the format of "ns:PORTENDPOINT_NAME" where ns is a namespace prefix valid at this scope. |
publish | Whether the endpoint should be published now, or whether it will be published at a later point. |
serviceName | The service name this service is implementing, it maps to the wsdl:service@name. In the format of "ns:SERVICE_NAME" where ns is a namespace prefix valid at this scope. |
wsdlLocation | The location of the WSDL. Can be on the classpath, file system, or be hosted remotely. |
bindingUri | The bindingUri for the service model to use |
address | The service publish address |
bus | The bus name that will be used in the jaxws endpoint. |
implementor | The implementor of jaxws endpoint. You can specify the implementor class name here, or just the ref bean name in the format of "#REF_BEAN_NAME" |
implementorClass | The implementor class name, it is really useful when you specify the implementor with the ref bean which is wrapped by using Spring AOP |
...
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 | ||||
---|---|---|---|---|
| ||||
<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);
}
}
|
The ProxyFactoryBean supports many other properties:
...
Code Block | ||||
---|---|---|---|---|
| ||||
GreeterService gs = new GreeterService(); Greeter greeter = gs.getGreeterPort(); org.apache.cxf.endpoint.Client client = org.apache.cxf.frontend.ClientProxy.getClient(greeter); org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint(); cxfEndpoint.getOutInterceptors().add(...); |
...
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(...);
|