加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

WebService服务及客户端调用简单实例

发布时间:2020-12-16 21:43:11 所属栏目:安全 来源:网络整理
导读:一、服务端 package io.renren.modules.webservice.service ; import javax.jws. WebService ; import javax.xml.ws.Endpoint ; /** * Created by Icebery on 2017/10/11. */ @WebService public class Function { //该方法就是要暴露给其他应用程序调用的方

一、服务端

package io.renren.modules.webservice.service;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;

/**  * Created by Icebery on 2017/10/11.  */ @WebService
public class Function {
    //该方法就是要暴露给其他应用程序调用的方法

    public String transWords(String words){
        String res="";
        res=words.toUpperCase();
//        for(char ch : words.toCharArray()){
//            res+="t"+ch+"t";
//        }
        return res;
    }

    //这里我们使用main方法来发布我们的service
    public static void  main(String[] args){
        Endpoint.publish("http://localhost:9001/Service/Function",new Function());
        System.out.println("Publish Success~");
    }
}


二、客户端调用

package io.renren.modules.webservice.service;

/**  * Created by Icebery on 2017/10/11.  */ public class TestWs {
    public static void main(String[] args){
        Function fu;
        fu=new Function();
        String str=fu.transWords("I Love Lee!");
        System.out.println(str);
}
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读