码迷,mamicode.com
首页 > 编程语言 > 详细

Spring 整合 webService

时间:2014-10-08 23:21:07      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:http   io   os   ar   java   sp   c   on   r   

创建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

标签:http   io   os   ar   java   sp   c   on   r   

原文地址:http://my.oschina.net/haopeng/blog/324992

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!