1. 发布webservice
步骤:
a)写一个接口
import javax.jws.WebService;
@WebService
public interface IMyWs {
public String getName(String name);
}
public class MyWs implements IMyWs {
@Override
public String getName(String name) {
return "your name is "+ name;
}
}
c)使用spring管理实现类bean的生命
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<bean id="myws" class="cn.com.sinosoft.uaams.service.impl.MyWs"></bean>
</beans>
d)在spring中配置webservice信息
<?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:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="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">
<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" />
<jaxws:endpoint id="myWs" implementorClass="cn.com.sinosoft.uaams.service.IMyWs" address="/myws">
<jaxws:implementor>
<bean id="myWsImpl" class="cn.com.sinosoft.uaams.service.impl.MyWs"></bean>
</jaxws:implementor>
</jaxws:endpoint>
</beans>