您的位置:首页 > 其它

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

2017-10-11 21:45 495 查看
一、服务端

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);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐