spring webservice

用spring配置webService:

一、server端配置:

1.在spring.xml中加入:

 <bean class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter">
  <property name="baseAddress" value="http://localhost:8888/bakebread_service/spring-ws/" />
 </bean>

2.在要发布的类中加入注解:

@Service
@WebService
public class WebServiceEndpointImpl implements WebServiceEndpoint{

 @WebMethod
 public void insertAccount() {
  System.out.println("Kevin WebService.");
 }
}
3.服务端的接口不用注解

二、client端配置:

1.在spring.xml中加入:

 <bean id="webServiceEndpoint"
  class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean">
  <property name="serviceInterface" value="com.kevin.rest.controller.WebServiceEndpoint" />
  <property name="wsdlDocumentUrl"
   value="http://localhost:8888/bakebread_service/spring-ws/webServiceEndpoint?wsdl" />
 </bean>

2.再把接口拿过来后,加入注解:

@WebService(serviceName = "WebServiceEndpointImplService", targetNamespace = "http://controller.rest.kevin.com/", portName = "WebServiceEndpointImplPort")
public interface WebServiceEndpoint {
 public void insertAccount();
}
3.完成以上配置后,WebServiceEndpoint 便可在client端当service用。

猜你喜欢

转载自qingwei201314.iteye.com/blog/1522834