spring 发布 Jax-Ws Service (二)
Service
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style; @WebService(targetNamespace="http://tempuri.org/")
@SOAPBinding(style=Style.DOCUMENT)
public interface MyService { @WebMethod
String sayHiTo(String name); @WebResult(name="sayHelloResult")
String sayHello(@WebParam(name="name")String name); }
Service Impl
import javax.annotation.Resource;
import javax.jws.WebService;
import javax.servlet.http.HttpServletRequest;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPMessageContext; @WebService(serviceName = "myService", targetNamespace = "http://tempuri.org/", endpointInterface = "cn.config.MyService")
public class MyServiceImpl implements MyService { @Override
public String sayHiTo(String name) {
return name;
} @Resource
private WebServiceContext wsc; @Override
public String sayHello(String name) {
MessageContext ctx = wsc.getMessageContext();
HttpServletRequest request = (HttpServletRequest) ctx.get(SOAPMessageContext.SERVLET_REQUEST);
return request.getContentType();
} }
javaBean Configuration
import org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter; @Configuration
public class WebServiceConfig { @Bean
public SimpleJaxWsServiceExporter simpleJaxWsServiceExporter() {
SimpleJaxWsServiceExporter sjaxWsServiceExporter = new SimpleJaxWsServiceExporter();
sjaxWsServiceExporter.setBaseAddress("http://localhost:8081/services/");
return sjaxWsServiceExporter;
} @Bean
public MyServiceImpl myServiceImpl() {
return new MyServiceImpl();
} }
服务器:tomcat 端口号:8081
wsdl:http://localhost:8081/services/helloservice?wsdl
说明及注意
(1)、通过http://localhost:8081/services/myService?wsdl 访问webservice部署描述符
还有自动生成的xsd:http://localhost:8081/services/myService?xsd=1 。
(2)、@SOAPBinding(parameterStyle=ParameterStyle.WRAPPED)
必须添加,否则会报错;另外,如果发布的方法只有一个参数可以使用@SOAPBinding(parameterStyle=ParameterStyle.BARE)。
(3)、@WebService(serviceName = "myService") 服务名称与Spring配置的bean一致。
(4)、webservice的端口设置不要与服务器一样,这一点非常重要否则服务器应用与webservice服务冲突会产生HTTP404错误。
spring 发布 Jax-Ws Service (二)的更多相关文章
- idea+maven+spring+cxf创建webservice应用(二)生成客户端程序
idea+maven+spring+cxf创建webservice应用(二)生成客户端程序,以上一篇为基础"idea+maven+spring+cxf创建webservice应用" ...
- 解决cxf+spring发布的webservice,types,portType和message以import方式导入
用cxf+spring发布了webservice,发现生成的wsdl的types,message和portType都以import的方式导入的.. 原因:命名空间问题 我想要生成的wsdl在同个文件中 ...
- 构建一个基于 Spring 的 RESTful Web Service
本文详细介绍了基于Spring创建一个“hello world” RESTful web service工程的步骤. 目标 构建一个service,接收如下HTTP GET请求: http://loc ...
- spring事务详解(二)简单样例
系列目录 spring事务详解(一)初探事务 spring事务详解(二)简单样例 spring事务详解(三)源码详解 spring事务详解(四)测试验证 spring事务详解(五)总结提高 一.引子 ...
- 使用Apache CXF和Spring集成创建Web Service(zz)
使用Apache CXF和Spring集成创建Web Service 您的评价: 还行 收藏该经验 1.创建HelloWorld 接口类 查看源码 打印? 1 package ...
- 使用CXF+Spring发布WebService,启动报错
使用CXF+Spring发布WebService,启动报错,日志如下: 五月 12, 2017 9:01:37 下午 org.apache.tomcat.util.digester.SetProper ...
- Spring框架学习之IOC(二)
Spring框架学习之IOC(二) 接着上一篇的内容,下面开始IOC基于注解装配相关的内容 在 classpath 中扫描组件 <context:component-scan> 特定组件包 ...
- 【Java Web开发学习】Spring发布RMI服务
[Java 远程服务]Spring发布RMI服务 转载:https://www.cnblogs.com/yangchongxing/p/9084066.html RmiServiceExporter可 ...
- spring cloud微服务实践二
在上一篇,我们已经搭建了spring cloud微服务中的注册中心.但只有一个注册中心还远远不够. 接下来我们就来尝试提供服务. 注:这一个系列的开发环境版本为 java1.8, spring boo ...
- Spring事务原理分析-部分二
Spring事务原理分析-部分二 说明:这是我在蚂蚁课堂学习了余老师Spring手写框架的课程的一些笔记,部分代码代码会用到余老师的课件代码.这不是广告,是我听了之后觉得很好. 课堂链接:Spring ...
随机推荐
- Android onConfigurationChanged 不执行
自从Android 3.2(API 13),screen size也开始跟着设备的横竖切换而改变. 所以,在AndroidManifest.xml里设置的MiniSdkVersion和 TargetS ...
- poj 3130 How I Mathematician Wonder What You Are! - 求多边形有没有核 - 模版
/* poj 3130 How I Mathematician Wonder What You Are! - 求多边形有没有核 */ #include <stdio.h> #include ...
- 8.volatile原子性
原子性 1.一个操作是不可中断的,即使多个线程在一起执行的时候,一旦操作执行开始,就不会被其他的线程干扰执行并导致执行中断. 2.对于静态变量int ,2个线程同时对它进行修改,线程a ...
- Unity3d笔试题大全
1. [C#语言基础]请简述拆箱和装箱. 答: 装箱操作: 值类型隐式转换为object类型或由此值类型实现的任何接口类型的过程. 1.在堆中开辟内存空间. 2.将值类型的数据复制到堆中. ...
- android中可以使用bitmap的平铺,镜像平铺等减小图片带来的apk过大的问题
bitmap的平铺.镜像drawable文件夹中新建bitmap,其中的tileMode属性 tileMode 属性就是用于定义背景的显示模式: disabled 默认值,表示不使用平铺 cla ...
- iPhone真机调试流程
大致流程:绑定设置ID--绑定电脑---绑定appbundle ID mac----钥匙串----证书助理-----从证书机构请求颁发证书-----填写邮件----生成证书到桌面 数据线连接设备--- ...
- MQTT---HiveMQ源代码具体解释(十八)Cluster-kryo与Serializer
源博客地址:http://blog.csdn.net/pipinet123 MQTT交流群:221405150 既然是Cluster,node之间肯定是须要交互的,那么肯定是须要序列化和反序列化.Hi ...
- 实战:sqlserver 日常检查脚本
--sqlserver 日常检查脚本 print '----------------------------' print ' 0.sqlserver all information ' print ...
- windows设置文件夹显示缩略图
windows设置文件夹显示缩略图 CreateTime--2017年7月26日16:32:59Author:Marydon 为什么要显示缩略图? a.显示缩略图后,图片文件能够直接显示内容,不能 ...
- IDEA中同窗口导入新的maven项目
创建请看这个:http://www.cnblogs.com/oskyhg/p/6649266.html 下边开始导入: 完毕. 结果展示: