从java 6之后就提供了简单快速的创建WebService的方法,这里将这种简单的方法记录下来方便以后回看。
第一步:首先创建一个java Project,然后创建一个类HelloWorldImpl如下:

package com.service.impl;

import javax.jws.WebService;

//@WebService用于标识该类为WebService类
@WebService
public class HelloWorldImpl {
    public String sayHello(String text) {
        return "Hello : " + text;
    }
}

第二步:创建一个主函数类,如下:

package com.service;

import javax.xml.ws.Endpoint;
import com.service.impl.HelloWorldImpl;

public class App {
    public static void main(String[] args) {
        String address = "http://127.0.0.1:8099/HelloWorld";
        Endpoint.publish(address, new HelloWorldImpl());
        System.out.println("发布消息成功");
    }
}

第三步:直接运行当前这个主方法,然后在浏览器输入如下地址即可验证是否成功:
http://127.0.0.1:8099/HelloWorld?wsdl

相关文章:

  • 2021-11-20
  • 2021-12-04
  • 2021-08-04
  • 2022-01-22
  • 2021-11-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-13
  • 2022-12-23
  • 2021-08-09
  • 2021-08-29
  • 2022-01-08
  • 2021-10-04
  • 2021-06-13
相关资源
相似解决方案