在CXF WebService (一) 中可以发现发布一个WS 服务还是很简单的,但是我们在Spring 中发布一个WS还有更简单的方法。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:task="http://www.springframework.org/schema/task" xmlns:util="http://www.springframework.org/schema/util"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
">
<context:annotation-config />
<context:component-scan base-package="com.*.*"/>
<!-- pool-size 是线程池的大小,queue-capacity 默认值是 Integer.MAX_VALUE -->
<task:executor id="executor" pool-size="100" />
<task:scheduler id="scheduler" pool-size="10"/>
<task:annotation-driven executor="executor" scheduler="scheduler"/>
<bean id="studentBiz" class="com.cathy.demo.aop.biz.StudentBizImpl"/>
<bean id="beforeAdvice" class="com.cathy.demo.aop.BeforeAdvice"/>
<aop:config>
<aop:aspect id="myAspect" ref="beforeAdvice">
<aop:before pointcut="execution(* com.cathy.demo.aop.biz.*.*(..))"
method="before"/>
</aop:aspect>
</aop:config>
<jaxws:endpoint id="helloWord" implementor="com.cathy.demo.cxf.impl.HelloWordImpl" address="http://localhost:8080/HelloWord"/>
</beans>
/**
*
* @author zhangwei
* @version $Id: AsyncDemoTest.java, v 0.1 2014年9月26日 下午10:43:43 zhangwei Exp $
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:META-INF/spring/*.xml")
public class AsyncDemoTest {
@Autowired
private TestClient testClient;
@Test
public void testAsync() throws InterruptedException {
testClient.operate();
TimeUnit.MINUTES.sleep(5);
}
}
在浏览器中输入:http://localhost:8080/HelloWord?wsdl
<?xml version="1.0" encoding="UTF-8"?>
-<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://com.cathy.demo" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" targetNamespace="http://com.cathy.demo" name="HelloWordService">
-<wsdl:types>
-<xs:schema xmlns:tns="http://com.cathy.demo" targetNamespace="http://com.cathy.demo" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" elementFormDefault="unqualified">
<xs:element name="sayHello" type="tns:sayHello"/>
<xs:element name="sayHelloResponse" type="tns:sayHelloResponse"/>
-<xs:complexType name="sayHello">
<xs:sequence/>
</xs:complexType>
-<xs:complexType name="sayHelloResponse">
<xs:sequence/>
</xs:complexType>
</xs:schema>
</wsdl:types>
-<wsdl:message name="sayHelloResponse">
<wsdl:part name="parameters" element="tns:sayHelloResponse"> </wsdl:part>
</wsdl:message>
-<wsdl:message name="sayHello">
<wsdl:part name="parameters" element="tns:sayHello"> </wsdl:part>
</wsdl:message>
-<wsdl:portType name="HelloWord">
-<wsdl:operation name="sayHello">
<wsdl:input name="sayHello" message="tns:sayHello"> </wsdl:input>
<wsdl:output name="sayHelloResponse" message="tns:sayHelloResponse"> </wsdl:output>
</wsdl:operation>
</wsdl:portType>
-<wsdl:binding name="HelloWordServiceSoapBinding" type="tns:HelloWord">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
-<wsdl:operation name="sayHello">
<soap:operation style="document" soapAction=""/>
-<wsdl:input name="sayHello">
<soap:body use="literal"/>
</wsdl:input>
-<wsdl:output name="sayHelloResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
-<wsdl:service name="HelloWordService">
-<wsdl:port name="HelloPort" binding="tns:HelloWordServiceSoapBinding">
<soap:address location="http://localhost:8080/HelloWord"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>