SpringBoot发布一个简单的WebService

上代码~

pom.xml:添加依赖

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency>

创建:WebService接口

import javax.jws.WebMethod;

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

创建:WebServiceImpl实现类

import com.jixing.test.webService.WebService;

import javax.jws.WebParam;

@javax.jws.WebService
public class WebServiceImpl implements WebService {

    @Override
    public String sayHello(@WebParam(name="name") String name) {
        return  name+"helloWebService~";
    }
}

创建:主启动类

import com.jixing.test.webService.impl.WebServiceImpl;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.xml.ws.Endpoint;

@SpringBootApplication
public class TestApplication {

    public static void main(String[] args) {
        SpringApplication.run(TestApplication.class, args);
        //发布服务
        String url = "http://localhost:9988/wsbServeice";
        Endpoint.publish(url,new WebServiceImpl());
        System.out.println("发布webService成功!");

    }

}

SoapUI工具访问WebService接口
1.File>New SOAP Project
在这里插入图片描述

2.Project Name:自定义项目名称
Initial WSDL:访问的wsdl地址
Create Requests:勾选,自动生成请求报文
在这里插入图片描述
3.SoapUI发送请求
在这里插入图片描述

Postman工具访问WebService接口

1.请求头添加:Content-Type:text/xml
在这里插入图片描述
2.Postman发送请求

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:impl="http://impl.webService.test.jixing.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <impl:sayHello>
         <!--Optional:-->
         <name>?</name>
      </impl:sayHello>
   </soapenv:Body>
</soapenv:Envelope>

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

qwuedh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值