返回WebServ......登陆

WebService的一些案例

阿神2016-11-08 09:04:54526

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

1

2

3

4

5

6

7

8

9

10

11

package cn.happy.webservice;

import javax.jws.WebService;

import javax.xml.ws.Endpoint;

@WebServicepublic 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去解析一些关键类   

11.png  

12.png

在提出一个测试类

1

2

3

4

5

6

7

8

9

10

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服务的方式

 13.png

     选取wsdl

14.png

最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送