spring实现部署webservice接口

spring和springboot都可实现
WebServiceApi.java
WebServiceApiImpl.java

package com.thy.custom.wsdl;

import org.json.simple.JSONObject;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

@WebService
public interface WebServiceApi {
    @WebMethod
    public String receiveSelfResultCallback(@WebParam(name = "file_num")String file_num,@WebParam(name = "dept_code") String dept_code,@WebParam(name = "result") String result);

    @WebMethod
    public String receiveArchiveResultCallback(@WebParam(name = "file_num")String file_num,@WebParam(name = "dept_code")String dept_code,@WebParam(name = "result")String result);

}

package com.thy.custom.wsdl;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

@WebService
public class WebServiceApiImpl implements WebServiceApi{

    @WebMethod
    public String receiveSelfResultCallback(@WebParam(name = "file_num")String file_num, @WebParam(name = "dept_code")String dept_code, @WebParam(name = "result")String result) {
        System.out.println("file_num:===========>"+file_num);
        System.out.println("dept_code:===========>"+dept_code);
        System.out.println("result:===========>"+result);
        return "1";
    }
    @WebMethod
    public String receiveArchiveResultCallback(@WebParam(name = "file_num")String file_num, @WebParam(name = "dept_code")String dept_code, @WebParam(name = "result")String result) {
        System.out.println("file_num:===========>"+file_num);
        System.out.println("dept_code:===========>"+dept_code);
        System.out.println("result:===========>"+result);
        return "1";
    }

}

设置为启动项目时启动webservice服务

	//启动时加载webservice服务
	public void webServiceT(){
			WebServiceApi ws = new WebServiceApiImpl();
			Endpoint.publish("http://0.0.0.0:8088/thy",ws);
			System.out.println("Webservice已发布");
		}

所需jar包

compile group: 'org.apache.cxf', name: 'cxf-rt-transports-http', version: '3.4.4'
compile group: 'org.apache.cxf', name: 'cxf-rt-transports-http-jetty', version: '3.4.4'
compile group: 'org.apache.cxf', name: 'cxf-rt-frontend-jaxws', version: '3.4.4'

接口地址:http://127.0.0.1:8088/thy?wsdl
命名空间:http://wsdl.custom.thy.com/
方法名:receiveSelfResultCallback,receiveArchiveResultCallback

在这里插入图片描述
该功能可以写在web项目中,作为web项目的一个对外接口
也可以单独部署一个项目或写一个java程序

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值