spring配置jax-ws
在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接口。
有六个参数可以配置:
- endpointInterface:指向一个定义此WebService抽象定义接口的完整类路径
- name:WebService名;默认的port名为"实现类名+Port",binding名为"实现类名+PortBinding",通过指定name的值来替换 实现类名。
- portName:指定port名,可以完成替换默认port名,或由上面的"name"指定的port名。
- targetNamespace:指定targetNamespace值,默认的值为 "http://包名/",可以通过此变量指定一个自定义的targetNamespace值。(注:如果分别定义接口和实现,则他们有各自的targetNamespace)
- serviceName:指定service名
- wsdlLocation:指向一个预定义的wsdl的文件,替代自动生成的wsdl文件。
@WebMethod:标注方法为webservice方法(可以省略)。
有三个参数可以配置:
- action:指定此方法对应的action
- exclude:true --表示此方法包含在web服务中;false表示排除此方法
- operationName:指定方法对应的operation的名字。
spring配置jax-ws的更多相关文章
- Spring配置c3p0数据源时出错报:java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector
今天在使用Spring配置c3p0数据源时,使用的数据库是mysql,服务器是tomcat,运行时报了一个 java.lang.NoClassDefFoundError: com/mchange/v2 ...
- Spring配置汇总
现在主流的JavaWeb应用几乎都会用到Spring,以下是Spring的配置,以及结合Web的SpringMVC配置的汇总. jar包的引入 与Web项目集成 Spring配置文件 SpringMV ...
- spring配置属性的两种方式
spring配置属性有两种方式,第一种方式通过context命名空间中的property-placeholder标签 <context:property-placeholder location ...
- 解决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 ...
- spring配置详解
1.前言 公司老项目的后台,均是基于spring框架搭建,其中还用到了log4j.jar等开源架包.在新项目中,则是spring和hibernate框架均有使用,利用了hibernate框架,来实现持 ...
- memcached 学习 1—— memcached+spring配置
memcached 学习目录: memcached 学习 1—— memcached+spring配置 这几天自己搭建项目环境,解决问题如下: 有关常见的配置这里没有列出,中间遇到的搭建问题比较顺利g ...
- 解决spring配置中的bean类型的问题:BeanNotOfRequiredTypeException
解决spring配置中的bean类型的问题:BeanNotOfRequiredTypeException这个问题出现的原因:一般在使用annotation的方式注入spring的bean 出现的,具体 ...
- spring配置中,properties文件以及xml文件配置问题
spring方便我们的项目快速搭建,功能强大,自然也会是体系复杂! 这里说下配置文件properties管理的问题. 一些不涉及到代码逻辑,仅仅只是配置数据,可以放在xxxx.properties文件 ...
- IntelliJ IDEA通过Spring配置连接MySQL数据库
先从菜单View→Tool Windows→Database打开数据库工具窗口,如下图所示: 点击Database工具窗口左上角添加按钮"+",选择Import from sour ...
- Dubbo中对Spring配置标签扩展
Spring提供了可扩展Schema的支持,完成一个自定义配置一般需要以下步骤: 设计配置属性和JavaBean 编写XSD文件 编写NamespaceHandler和BeanDefinitionPa ...
随机推荐
- json_encode转义中文问题
默认情况下php的 json_decode 方法会把特殊字符进行转义,还会把中文转为Unicode编码形式. 这使得数据库查看文本变得很麻烦.所以我们需要限制对于中文的转义. 对于PHP5.4+版本, ...
- 使用spring的特殊bean完成分散配置
1.在使用分散配置时,spring的配置文件applicationContext.xml中写法如下: <!-- 引入db.properties文件, --> <context:pro ...
- 水题 O
Bob 和 Alice 开始使用一种全新的编码系统.它是一种基于一组私有钥匙的.他们选择了n个不同的数a1 , . . .,an, 它们都大于0小于等于n. 机密过程如下:待加密的信息放置在这组加密钥 ...
- workerman 7272端口被占用
1/问题:workerman 7272端口被占用 2/策略: 1.查找被占用的端口 netstat -tln netstat -tln | grep 8083 netstat -tln 查看端口使用情 ...
- docker能用来干嘛
http://blog.csdn.net/wangtaoking1/article/details/44340445 什么是Docker Docker 是一个开源项目,诞生于 2013 年初,最初 ...
- ymPrompt,jcs缓存架构
jcs.auxiliary.LTCP=org.apache.jcs.auxiliary.lateral.socket.tcp.LateralTCPCacheFactory#jcs.auxiliary. ...
- bzoj4444 国旗计划
题目链接 倍增,预处理出每个点往后$2^i$个应该选哪个人 我用的treap就是快 #include<algorithm> #include<iostream> #includ ...
- python sqlite3 数据库操作
python sqlite3 数据库操作 SQLite3是python的内置模块,是一款非常小巧的嵌入式开源数据库软件. 1. 导入Python SQLite数据库模块 import sqlite3 ...
- 导弹拦截 p1020
第一问就是求最长不上升子序列的长度,要写O(nlogn)的算法.... 对于这种nlogn的算法,只能求出长度,不能求出具体的序列.这种算法实现过程如下: 我们定义len为到目前为止最长不上升子序列的 ...
- QQ项目(续)
1.项目查找好友的原理 sql:select * from qquser where account in(select friendAccount from friend where userAcc ...