zoukankan      html  css  js  c++  java
  • WebService的一些案例

           既然要实现WebService,首先先来创建一个Service类

    package cn.happy.webservice;
    
    import javax.jws.WebService;
    import javax.xml.ws.Endpoint;
    @WebService
    public class Service {
        
    
        public void say(String name){
              System.out.println("Hello"+name);
          }
          public static void main(String[] args) {
             Endpoint.publish("http://localhost:50000/hello", new Service());
             System.out.println("server is listening ....");
          }
    }

             根据上面创建的服务http://localhost:50000/hello添加?wsdl去解析一些关键类

      

          

              在提出一个测试类

    package test;
    
    import cn.happy.service.Service;
    import cn.happy.service.ServiceService;
    
    public class MyTest {
    
        /**
         * @param args
         */
        public static void main(String[] args) {
            ServiceService service=new ServiceService();
            Service port=service.getServicePort();
            port.say("好好好");
        }
    
    }

        另外还有一些连接别的service服务的方式

         选取wsdl

         也可以直接通过http://192.168.15.54:50000/hello去网页访问,

  • 相关阅读:
    django-高级
    django-模板
    django-视图
    django笔记一
    redis、mysql、mongodb数据库
    Scrapy-redis分布式+Scrapy-redis实战
    python2 'ascii'编码问题
    【java8新特性】方法引用
    java浮点数运算无法精确的问题
    java中Array和ArrayList区别
  • 原文地址:https://www.cnblogs.com/bdpsc/p/6036170.html
Copyright © 2011-2022 走看看