1. Server side
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 {//This method is to be exposed to other applications to call public String transWords span>(String words){ String res=""; res=words.toUpperCase();// for(char ch: words .toCharArray()){// res+=" "+ch+" ";// } return res; } //Here we use the main method to publish our service< span style="color:#808080"> public static void main(String [] args){ Endpoint.publish("http://localhost:9001/Service/Function"< /span>,new Function()); System.out.println ("Publish Success~"); < /span>})
Second, client call
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); }}