webservice项目实战之服务端

在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。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值