在web项目中应用webservice。
服务端:
1、创建接口
package com.edarong.suppsys.webservice;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.ws.BindingType;
import javax.xml.ws.soap.SOAPBinding;
import com.edarong.suppsys.bean.ContentList;
@WebService
@BindingType(value=SOAPBinding.SOAP12HTTP_BINDING)
public interface BWService111 {
@WebMethod
public ContentList getContentByDate(
@WebParam(name = "sysnum") String sysnum,
@WebParam(name = "createdDate") String createdDate,
@WebParam(name = "reload") String reload);
}
2、实现类
package com.edarong.suppsys.webservice.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import com.edarong.suppsys.bean.ContentList;
import com.edarong.suppsys.webservice.BWService111;
public class BWServiceImpl111 implements BWService111 {
@Autowired
private JdbcTemplate jdbcTemplate;
public ContentList getContentByDate(java.lang.String sysnum,
java.lang.String createdDate, java.lang.String reload) {
System.out.println(sysnum);
System.out.println(createdDate);
System.out.println(reload);
ContentList contentList = new ContentList();
contentList.setCode("1");
contentList.setDesc("执行成功");
contentList.setStatus("1");
try {
System.err.println("========================");
} catch (java.lang.Exception ex) {
ex.printStackTrace();
contentList.setCode("0");
contentList.setDesc("执行失败");
contentList.setStatus("0");
contentList.setPlanNewlist(null);
}
return contentList;
}
}
3、cxf.xml中注册
<?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"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd">
</jaxws:server>
<bean id="bwServiceImpl111" class="com.edarong.suppsys.webservice.impl.BWServiceImpl111" />
<jaxws:server id="bwService111" serviceClass="com.edarong.suppsys.webservice.BWService111" address="/bwService111">
<jaxws:serviceBean><ref bean="bwServiceImpl111"/></jaxws:serviceBean>
</jaxws:server>
</beans>
4、访问
http://127.0.0.1:8080/ewRosaChinensis/services/bwService111?wsdl
浏览器显示wsdl。