Spring 整合 webService

创建webservice实现类

@Component
@WebService(serviceName="ledgerWebService") 
public class LedgerWebServcie {
	
	@WebMethod
	public String saveInstituteDispatch(
			@WebParam(name="unitName") String unitName,
			@WebParam(name="colonelName") String colonelName,
		){
	 try {
		jsonObject.put("status", 0);
		
		return jsonObject.toJSONString();
	}
}
注:此类中不要出现 get/set 用于Spring注入的方法,采用Spring的注解的方式;

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:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
    <!-- 配置webservce -->
    <bean class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter"
    p:baseAddress="http://localhost:8081/"></bean>
    
</beans>


访问:
http://127.0.0.1:8081/ledgerWebService?wsdl



你可能感兴趣的:(spring,webservice,整合)