PostMan请求Web Service接口

在这里插入图片描述

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xxx="http://tempuri.org/xxx.xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
 <soapenv:Header></soapenv:Header>
 <soapenv:Body>
 <sayHello xmlns="http://service.mycode.com/">
    <uname>123456</uname>
 </sayHello>
 </soapenv:Body>
</soapenv:Envelope>
<!-- sayHello是方法名 uname 是参数名 123456 是要传的值 xmlns="http://service.mycode.com/"是后台配置的 targetNamespace = "http://service.mycode.com/"-->
<!-- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <sayHello xmlns="http://service.mycode.com/">
      <uname>青山隐隐水迢迢</uname>
    </sayHello>
  </soap:Body> 
</soap:Envelope> -->

后台代码

import com.mycode.service.NetbarServices;
import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.el.ELManager;
import javax.xml.ws.Endpoint;

@Configuration
public class CxfConfig {
    @Autowired
    private Bus bus;
    @Autowired
    private NetbarServices netbarServices;

    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(bus,netbarServices);
		 //明确(暴露)该服务的接口地址,防止nginx代理时丢失端口(也可以服务器开通该端口)
//        endpoint.setPublishedEndpointUrl("127.0.0.1:701/webservice/pushProperData?wsdl");
//        endpoint.getInInterceptors().add(new AuthInterceptor());
        endpoint.publish("/NetbarServices");//接口发布在 /NetbarServices 目录下
        return endpoint;
    }
}
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;

/**
 * 网吧web services 接口
 * @author xiaojf 2017/7/24 21:35
 */
@WebService// 命名空间,一般是接口的包名倒序
public interface NetbarServices {
    @WebMethod
    String sayHello(@WebParam(name = "uname", targetNamespace = "http://service.mycode.com/") String uname);
}

import javax.jws.WebParam;
import javax.jws.WebService;

import org.springframework.stereotype.Component;

/**
 *  网吧web services 接口实现
 * @author xiaojf 2017/7/24 21:38
 */
@WebService(serviceName = "NetbarServices"//服务名
        ,targetNamespace = "http://service.mycode.com/"//包名倒序,并且和接口定义保持一致
        ,endpointInterface = "com.mycode.service.NetbarServices")//包名
@Component
public class NetbarServicesImpl implements NetbarServices {
    @Override
    public String sayHello(String uname) {
        System.out.println("vdsvfsvdsvdsvdsvdsv");
        return "hello , "+ uname;
    }
}

application.properties

#开发环境
server.port=701
cxf.path=/webservice
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

HHUFU..

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

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

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

打赏作者

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

抵扣说明:

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

余额充值