zoukankan      html  css  js  c++  java
  • 使用JDK创建webService

    1、建一个接口类

    package ws;
    import javax.jws.WebMethod;
    import javax.jws.WebService;
    
    @WebService
    public interface HelloWS {
    	
    	@WebMethod
    	public String sayHello(String name);
    }
    

    2、建一个实现类

    package ws;
    import javax.jws.WebService;
    
    @WebService
    public class HelloWSImpl implements HelloWS {
    
    	@Override
    	public String sayHello(String name) {
    		// TODO Auto-generated method stub
    		System.out.println("Server" + name);
    		return "Hello"+name;
    	}
    }
    

    3、发布测试类

    package ws;
    import javax.xml.ws.Endpoint;
    
    public class ServerTest {
    	public static void main(String[] args) {
    		String addreess = "http://localhost:8080/hellows";
    		Endpoint.publish(addreess, new HelloWSImpl());
    		System.out.println("发布成功");
    	}
    }
    

    4、调用成功

      浏览器访问:http://localhost:8080/hellows

  • 相关阅读:
    hlgoj 1766 Cubing
    Reverse Linked List
    String to Integer
    Bitwise AND of Numbers Range
    Best Time to Buy and Sell Stock III
    First Missing Positive
    Permutation Sequence
    Next Permutation
    Gray Code
    Number of Islands
  • 原文地址:https://www.cnblogs.com/wwssgg/p/15101848.html
Copyright © 2011-2022 走看看