博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
spring配置jax-ws
阅读量:4494 次
发布时间:2019-06-08

本文共 1516 字,大约阅读时间需要 5 分钟。

在spring配置文件中新建bean(或者是在配置文件中添加bean),在该bean中添加指定的访问地址。

@Bean    public static SimpleJaxWsServiceExporter getSimpleJaxWsServiceExporter(){        SimpleJaxWsServiceExporter wsServiceExporter = new SimpleJaxWsServiceExporter();        wsServiceExporter.setBaseAddress("http://localhost:8088/sgyws");        return wsServiceExporter;    }

然后新建一个接口

@WebServicepublic interface SgyWs {    @WebMethod    public String sayHi(); }

再有一个实现类,该类上的注解serviceName为ws的服务名,endpointInterface为接口地址。

@WebService(serviceName="/sgyService",endpointInterface="com.btw.sgy.webService.SgyWs")//@SOAPBinding(style=Style.RPC)@Componentpublic class SgyWsImpl implements SgyWs{    @Override    public String sayHi(){        System.out.print("hi");    };}

最后启动服务即可,访问地址为http://localhost:8088/sgyws/sgyService。

如果在第一步中,不加"/",则访问地址会变为http://localhost:8088/sgywssgyService。

 

在jax-ws中,有两种重要的annotation:

  • @WebService
  • @WebMethod

@WebService:标识某个类,或某个接口,为webService接口。

  有六个参数可以配置:

  1. endpointInterface:指向一个定义此WebService抽象定义接口的完整类路径
  2. name:WebService名;默认的port名为"实现类名+Port",binding名为"实现类名+PortBinding",通过指定name的值来替换 实现类名。
  3. portName:指定port名,可以完成替换默认port名,或由上面的"name"指定的port名。
  4. targetNamespace:指定targetNamespace值,默认的值为 "http://包名/",可以通过此变量指定一个自定义的targetNamespace值。(注:如果分别定义接口和实现,则他们有各自的targetNamespace)
  5. serviceName:指定service名
  6. wsdlLocation:指向一个预定义的wsdl的文件,替代自动生成的wsdl文件。

@WebMethod:标注方法为webservice方法(可以省略)。

  有三个参数可以配置:

  1. action:指定此方法对应的action
  2. exclude:true --表示此方法包含在web服务中;false表示排除此方法
  3. operationName:指定方法对应的operation的名字。

 

转载于:https://www.cnblogs.com/yxth/p/8425995.html

你可能感兴趣的文章
zookeeper + dubbo 搭建
查看>>
根据前序遍历和中序遍历求出二叉树并打印
查看>>
UOJ356 [JOI2017春季合宿] Port Facility 【启发式合并】【堆】【并查集】
查看>>
Delphi的命令行编译命令
查看>>
BZOJ 1901 Zju2112 Dynamic Rankings 题解
查看>>
C++虚析构函数
查看>>
《玩转.NET Micro Framework 移植-基于STM32F10x处理器》--微软中国.NET Micro Framework项目组工程师所作之序...
查看>>
php服务端搜索,功能改进
查看>>
unity, 在surface shader中访问顶点色
查看>>
Spring声明式事务配置
查看>>
并查集的实现
查看>>
Leetcode 350. Intersection of Two Arrays II
查看>>
EditPlus VC2010 and 2008 C/C++配置
查看>>
Practical Lessons from Predicting Clicks on Ads at Facebook
查看>>
JFrame面板
查看>>
Android自动化压力测试之Monkey Test 异常解读(五)
查看>>
Compressing Convolutional Neural Networks in the Frequency Domain 论文笔记
查看>>
设计模式:单例和多例
查看>>
Myslq 之修改数据库
查看>>
maven工程转为web工程时没有add web project capabilities选项的解决办法
查看>>