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

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

然后新建一个接口

@WebService
public interface SgyWs { @WebMethod
public String sayHi();

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

@WebService(serviceName="/sgyService",endpointInterface="com.btw.sgy.webService.SgyWs")
//@SOAPBinding(style=Style.RPC)
@Component
public 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的名字。

spring配置jax-ws的更多相关文章

  1. Spring配置c3p0数据源时出错报:java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector

    今天在使用Spring配置c3p0数据源时,使用的数据库是mysql,服务器是tomcat,运行时报了一个 java.lang.NoClassDefFoundError: com/mchange/v2 ...

  2. Spring配置汇总

    现在主流的JavaWeb应用几乎都会用到Spring,以下是Spring的配置,以及结合Web的SpringMVC配置的汇总. jar包的引入 与Web项目集成 Spring配置文件 SpringMV ...

  3. spring配置属性的两种方式

    spring配置属性有两种方式,第一种方式通过context命名空间中的property-placeholder标签 <context:property-placeholder location ...

  4. 解决eclipse spring配置报错:cvc-elt.1: Cannot find the declaration of element

    解决eclipse spring配置报错:cvc-elt.1: Cannot find the declaration of element 'beans'.Referenced file conta ...

  5. spring配置详解

    1.前言 公司老项目的后台,均是基于spring框架搭建,其中还用到了log4j.jar等开源架包.在新项目中,则是spring和hibernate框架均有使用,利用了hibernate框架,来实现持 ...

  6. memcached 学习 1—— memcached+spring配置

    memcached 学习目录: memcached 学习 1—— memcached+spring配置 这几天自己搭建项目环境,解决问题如下: 有关常见的配置这里没有列出,中间遇到的搭建问题比较顺利g ...

  7. 解决spring配置中的bean类型的问题:BeanNotOfRequiredTypeException

    解决spring配置中的bean类型的问题:BeanNotOfRequiredTypeException这个问题出现的原因:一般在使用annotation的方式注入spring的bean 出现的,具体 ...

  8. spring配置中,properties文件以及xml文件配置问题

    spring方便我们的项目快速搭建,功能强大,自然也会是体系复杂! 这里说下配置文件properties管理的问题. 一些不涉及到代码逻辑,仅仅只是配置数据,可以放在xxxx.properties文件 ...

  9. IntelliJ IDEA通过Spring配置连接MySQL数据库

    先从菜单View→Tool Windows→Database打开数据库工具窗口,如下图所示: 点击Database工具窗口左上角添加按钮"+",选择Import from sour ...

  10. Dubbo中对Spring配置标签扩展

    Spring提供了可扩展Schema的支持,完成一个自定义配置一般需要以下步骤: 设计配置属性和JavaBean 编写XSD文件 编写NamespaceHandler和BeanDefinitionPa ...

随机推荐

  1. 29.html5 移动端开发总结

    手机与浏览器 浏览器: 移动端开发主要针对手机,ipad等移动设备,随着地铁里的低头族越来越多,移动端开发在前端的开发任务中站的比重也越来越大.各种品牌及尺寸的手机也不尽相同.尺寸不同就算了分辨率,视 ...

  2. linux 小笔记

    //强杀pid2306的进程 kill -9 2306 //查看80端口占用情况 lsof -i :80 //杀死mysql的所有进程 sudo killall mysqld //关闭占用80端口的所 ...

  3. Hive自定义函数UDF和UDTF

    UDF(user defined functions) 用于处理单行数据,并生成单个数据行. PS: l 一个普通UDF必须继承自“org.apache.hadoop.hive.ql.exec.UDF ...

  4. mysql----------局域网数据库:如何让navicat链接局域网其他的数据库。

    1.找到被链接的数据库,打开以后有一个自带的mysql数据库,打开以后下面有一个user表,把里面的第一条数据的第一个字段改成% 百分号,然后保存,重启数据库,搞定 2.如果是linux下的话,记得把 ...

  5. tp命名空间

    namespace   Home\Controller;  命名空间   根命名空间下的类所在的文件夹use Think\Controller; 使用   根命名空间下的controller类 顶头写 ...

  6. Shader2.0常用语义

    POSITION: 获取模型顶点的信息.NORMAL: 获取法线信息TEXCOORD(n):        高精度的从顶点传递信息到片段着色器COLOR:     表示低精度从顶点传递信息到片段着色器 ...

  7. lua学习之循环打印九九乘法表

    --第4题 输出99乘法表 function PrintMulitiplyTable() , do local res = {} local str = "" , i do res ...

  8. GridFS Example

    http://api.mongodb.com/python/current/examples/gridfs.html This example shows how to use gridfs to s ...

  9. 转:MD5辅助类

    public class MD5Helper { private static MD5 md5 = new MD5CryptoServiceProvider(); private static str ...

  10. 什么是 shell

     shell 在计算机科学中,Shell俗称壳(用来区别于核),是指“为使用者提供操作界面”的软件(命令解析器).它类似于DOS下的command.com和后来的cmd.exe.它接收用户命令,然后调 ...