- 浏览: 545920 次
- 性别:
文章分类
- 全部博客 (337)
- WEB前端@HTML (4)
- WEB前端@CSS (5)
- WEB前端@javascript (31)
- WEB前端@DHTML (8)
- WEB前端@jQuery (3)
- WEB前端@Flex4 (19)
- WEB前端@BootStrap3 (21)
- 数据交换@JSON (1)
- 模板标签@JSTL (1)
- 模板标签@Thymeleaf (1)
- 模板标签@XSL-FO (3)
- WEB后台@JavaSE (75)
- WEB后台@JAX-WS (27)
- WEB后台@HttpClient (0)
- WEB后台@SSO (2)
- 框架@Spring3 (3)
- 框架@spring_MVC (8)
- 框架@Hibernate (26)
- 框架@play framework (18)
- 框架@sl4j (4)
- 数据库@ (2)
- 数据库@JDBC (0)
- 服务器@Linux (14)
- 服务器@Tomcat (2)
- 第三方jar@dom4j (1)
- 第三方jar@POI (2)
- 第三方jar@CXF (5)
- 项目管理@Maven (22)
- 项目管理@SVN (1)
- 缓存管理@ehcache (1)
- 系统设计@设计模式 (10)
- 单元测试@JunitTest (1)
- 开发工具 (3)
- BUG收录 (1)
- 学习之路 (6)
- 面试之道 (1)
- 我的项目 (2)
最新评论
-
superich2008:
logback配置文件的改动会导致应用重新加载,多改动几次后就 ...
Chapter 3: Logback configuration -
chenzhihui:
不是可以在log4j中配置以控制台或者文件方式保存日志的?
play记录日志 -
smilease:
很棒,正缺这个,非常感谢
bootstrap3-typeahead 自动补全 -
guangling13345:
[size=x-small][/size]
二级联动菜单 -
jacksondesign:
有,和YAML的格式有关,不知道有没有什么好的YAML格式的验 ...
(四)play之yabe项目【页面】
http://localhost:8888/numberService?wsdl
type节点分析
type用来定义访问的类型,即方法入参的个数,类型和返回值的类型
http://localhost:8888/numberService?xsd=1
message节点分析
message节点用来传递消息---SOAP simple object access protocol
每个方法都有入参和返回值,这些数据就是通过message来进行传递的
客户端通过message节点传递参数到服务端,服务端执行方法,返回值又通过message节点来传递数据。一个方法至少对于2个message节点!
portType节点分析
portType指名对外暴露的接口名称
operation 指定被访问的方法
input 指定方法的入参(指定入参对应的message)
output 指定方法的返回值(指定返回值对应的message)
binding节点分析
bingding节点主要用于指定SOAP消息以何种方式/样式进行传递
service节点分析
结合前面的SOAP消息传输、接口和方法(参数和返回值)的说明、SOAP消息(message)来提供一个服务
通过该服务即可调用webservice对外提供的方法
SOAP
SOAP通过"信封"传递消息
信封:携带方法的入参
信封:携带方法的返回值
定制SOAP中的参数名
通过注解详细说明wsdl中的参数名称,否则默认使用args0,args1...来表示形参
服务接口中使用注解定义如下:
通过注解标注了参数后,SOAP中的参数名就是指定的名称了
<?xml version="1.0"?> <!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. --> <!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. --> <definitions targetNamespace="http://service.hqh.com/" name="MyServiceImplService"> <types> <xsd:schema> <xsd:import namespace="http://service.hqh.com/" schemaLocation="http://localhost:8888/numberService?xsd=1"/> </xsd:schema> </types> <message name="plus"> <part name="parameters" element="tns:plus"/> </message> <message name="plusResponse"> <part name="parameters" element="tns:plusResponse"/> </message> <message name="minus"> <part name="parameters" element="tns:minus"/> </message> <message name="minusResponse"> <part name="parameters" element="tns:minusResponse"/> </message> <portType name="IMyService"> <operation name="plus"> <input message="tns:plus"/> <output message="tns:plusResponse"/> </operation> <operation name="minus"> <input message="tns:minus"/> <output message="tns:minusResponse"/> </operation> </portType> <binding name="MyServiceImplPortBinding" type="tns:IMyService"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <operation name="plus"> <soap:operation soapAction=""/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> <operation name="minus"> <soap:operation soapAction=""/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> </binding> <service name="MyServiceImplService"> <port name="MyServiceImplPort" binding="tns:MyServiceImplPortBinding"> <soap:address location="http://localhost:8888/numberService"/> </port> </service> </definitions>
type节点分析
type用来定义访问的类型,即方法入参的个数,类型和返回值的类型
<definitions targetNamespace="http://service.hqh.com/" name="MyServiceImplService"> <types> <xsd:schema> <xsd:import namespace="http://service.hqh.com/" schemaLocation="http://localhost:8888/numberService?xsd=1"/> </xsd:schema> </types> </definitions>
http://localhost:8888/numberService?xsd=1
<?xml version="1.0"?> <!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. --> <xs:schema version="1.0" targetNamespace="http://service.hqh.com/"> <!--方法A的参数--> <xs:element name="minus" type="tns:minus"/> <!--方法A的返回值--> <xs:element name="minusResponse" type="tns:minusResponse"/> <!--方法B的参数--> <xs:element name="plus" type="tns:plus"/> <!--方法B的返回值--> <xs:element name="plusResponse" type="tns:plusResponse"/> <!--方法A的参数信息--> <xs:complexType name="minus"> <xs:sequence> <xs:element name="arg0" type="xs:int"/> <xs:element name="arg1" type="xs:int"/> </xs:sequence> <!--方法A的返回值信息--> </xs:complexType> <xs:complexType name="minusResponse"> <xs:sequence> <xs:element name="return" type="xs:int"/> </xs:sequence> </xs:complexType> <!--方法B的参数信息--> <xs:complexType name="plus"> <xs:sequence> <xs:element name="arg0" type="xs:int"/> <xs:element name="arg1" type="xs:int"/> </xs:sequence> </xs:complexType> <!--方法B的返回值信息--> <xs:complexType name="plusResponse"> <xs:sequence> <xs:element name="return" type="xs:int"/> </xs:sequence> </xs:complexType> </xs:schema>
message节点分析
message节点用来传递消息---SOAP simple object access protocol
每个方法都有入参和返回值,这些数据就是通过message来进行传递的
客户端通过message节点传递参数到服务端,服务端执行方法,返回值又通过message节点来传递数据。一个方法至少对于2个message节点!
<?xml version="1.0"?> <!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. --> <!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. --> <definitions targetNamespace="http://service.hqh.com/" name="MyServiceImplService"> <types> <xsd:schema> <xsd:import namespace="http://service.hqh.com/" schemaLocation="http://localhost:8888/numberService?xsd=1"/> </xsd:schema> </types> <!--传递plus()的入参--> <message name="plus"> <part name="parameters" element="tns:plus"/> </message> <!--传递plus()返回的消息--> <message name="plusResponse"> <part name="parameters" element="tns:plusResponse"/> </message> <!--传递minus()的入参--> <message name="minus"> <part name="parameters" element="tns:minus"/> </message> <!--传递minus()返回的消息--> <message name="minusResponse"> <part name="parameters" element="tns:minusResponse"/> </message> </definitions>
portType节点分析
portType指名对外暴露的接口名称
operation 指定被访问的方法
input 指定方法的入参(指定入参对应的message)
output 指定方法的返回值(指定返回值对应的message)
<?xml version="1.0"?> <!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. --> <!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. --> <definitions targetNamespace="http://service.hqh.com/" name="MyServiceImplService"> <types> <xsd:schema> <xsd:import namespace="http://service.hqh.com/" schemaLocation="http://localhost:8888/numberService?xsd=1"/> </xsd:schema> </types> <message name="plus"> <part name="parameters" element="tns:plus"/> </message> <message name="plusResponse"> <part name="parameters" element="tns:plusResponse"/> </message> <message name="minus"> <part name="parameters" element="tns:minus"/> </message> <message name="minusResponse"> <part name="parameters" element="tns:minusResponse"/> </message> <!-- 服务器端的接口 --> <portType name="IMyService"> <!--接口中的方法--> <operation name="plus"> <!--方法的入参通过name="tns:plus"的message传递--> <input message="tns:plus"/> <!--方法的返回值通过name="tns:plusResponse"的message传递--> <output message="tns:plusResponse"/> </operation> <operation name="minus"> <input message="tns:minus"/> <output message="tns:minusResponse"/> </operation> </portType> </definitions>
binding节点分析
bingding节点主要用于指定SOAP消息以何种方式/样式进行传递
<?xml version="1.0"?> <!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. --> <!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. --> <definitions targetNamespace="http://service.hqh.com/" name="MyServiceImplService"> <types> <xsd:schema> <xsd:import namespace="http://service.hqh.com/" schemaLocation="http://localhost:8888/numberService?xsd=1"/> </xsd:schema> </types> <message name="plus"> <part name="parameters" element="tns:plus"/> </message> <message name="plusResponse"> <part name="parameters" element="tns:plusResponse"/> </message> <message name="minus"> <part name="parameters" element="tns:minus"/> </message> <message name="minusResponse"> <part name="parameters" element="tns:minusResponse"/> </message> <portType name="IMyService"> <operation name="plus"> <input message="tns:plus"/> <output message="tns:plusResponse"/> </operation> <operation name="minus"> <input message="tns:minus"/> <output message="tns:minusResponse"/> </operation> </portType> <!-- 指定SOAP消息传递所使用的格式 --> <binding name="MyServiceImplPortBinding" type="tns:IMyService"> <!-- SOAP使用document的风格进行传递(原来使用RBC的风格) --> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <!-- plus()的消息传递 --> <operation name="plus"> <soap:operation soapAction=""/> <!--输入消息通过literal方式进行传递(jdk1.6之前使用SOAPMessage encode方式传递)--> <input> <soap:body use="literal"/> </input> <!--输出消息通过literal--> <output> <soap:body use="literal"/> </output> </operation> <!-- minus()的消息传递 --> <operation name="minus"> <soap:operation soapAction=""/> <!--输入消息通过literal方式进行传递 --> <input> <soap:body use="literal"/> </input> <!--输出消息通过literal--> <output> <soap:body use="literal"/> </output> </operation> </binding> </definitions>
service节点分析
结合前面的SOAP消息传输、接口和方法(参数和返回值)的说明、SOAP消息(message)来提供一个服务
通过该服务即可调用webservice对外提供的方法
<?xml version="1.0"?> <!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. --> <!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. --> <definitions targetNamespace="http://service.hqh.com/" name="MyServiceImplService"> <types> <xsd:schema> <xsd:import namespace="http://service.hqh.com/" schemaLocation="http://localhost:8888/numberService?xsd=1"/> </xsd:schema> </types> <message name="plus"> <part name="parameters" element="tns:plus"/> </message> <message name="plusResponse"> <part name="parameters" element="tns:plusResponse"/> </message> <message name="minus"> <part name="parameters" element="tns:minus"/> </message> <message name="minusResponse"> <part name="parameters" element="tns:minusResponse"/> </message> <portType name="IMyService"> <operation name="plus"> <input message="tns:plus"/> <output message="tns:plusResponse"/> </operation> <operation name="minus"> <input message="tns:minus"/> <output message="tns:minusResponse"/> </operation> </portType> <binding name="MyServiceImplPortBinding" type="tns:IMyService"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <operation name="plus"> <soap:operation soapAction=""/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> <operation name="minus"> <soap:operation soapAction=""/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> </binding> <!--指定服务的名称(同definitions的name属性)--> <service name="MyServiceImplService"> <!--prot的name属性指定的端口(一个方法)将返回服务接口的一个实现,该实现基于name="MyServiceImplPortBinding"的SOAP消息定义进行创建--> <port name="MyServiceImplPort" binding="tns:MyServiceImplPortBinding"> <!--指定服务对外发布的地址--> <soap:address location="http://localhost:8888/numberService"/> </port> </service> </definitions>
SOAP
SOAP通过"信封"传递消息
信封:携带方法的入参
<?xml version="1.0"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" <!--对外发布的服务所在的包(逆序)--> xmlns:q0="http://service.hqh.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <q0:plus> <arg0>1</arg0> <arg1>2</arg1> </q0:plus> </soapenv:Body> </soapenv:Envelope>
信封:携带方法的返回值
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Body> <ns2:plusResponse xmlns:ns2="http://service.hqh.com/"> <return>3</return> </ns2:plusResponse> </S:Body> </S:Envelope>
定制SOAP中的参数名
通过注解详细说明wsdl中的参数名称,否则默认使用args0,args1...来表示形参
服务接口中使用注解定义如下:
@WebService public interface IMyService { @WebResult(name="plusResult") public int plus(@WebParam(name="a")int a,@WebParam(name="b")int b); @WebResult(name="minusResult") public int minus(@WebParam(name="a")int a,@WebParam(name="b")int b); }
通过注解标注了参数后,SOAP中的参数名就是指定的名称了
<?xml version="1.0"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://service.hqh.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <q0:plus> <a>5</a> <!--信封中参数名称为注解所标注的名称--> <b>7</b> <!--信封中参数名称为注解所标注的名称--> </q0:plus> </soapenv:Body> </soapenv:Envelope>
发表评论
-
实际应用-使用xsd定义Model对象
2014-02-27 02:24 1291使用schema定义Model 好 ... -
XJC 将schema转换为java类
2013-08-28 09:55 1816使用xjc(xml java change)将schema转 ... -
Webservice中获取Servlet的相关对象
2013-08-15 17:44 2860第一种方式: 通过注入WebServiceContex ... -
JAX与spring的无缝集成---增加Handler和Exception(二)
2013-08-15 16:00 1959客户端也使用spring集成JAX-WS。但是有一个问题需 ... -
Exception处理:服务端返回对象与客户端类型不一致XXX cannot be cast to XXX
2013-08-15 13:52 2578描述: 服务端向客户端返回数据时,发生类型转 ... -
JAX与spring的无缝集成(一)
2013-08-13 13:45 6583JAX-WS与spring集成有几 ... -
使用契约优先---重要注意事项
2013-08-11 22:23 993使用契约优先编写schema和wsdl文件时,一般都是在ws ... -
通过HEADER传递信息-做权限控制
2013-08-08 18:11 2000通过HEADER而不是BODY传递“LICENSE” ... -
webservice传递二进制数据(文件)
2013-08-08 16:14 2193将二进制数据放到Attachment中进行传递,而不是放到 ... -
发布webservice到tomcat
2013-08-07 09:39 3017目标: 基于契约优先的webservice功能开发 ... -
基于契约优先的隐式头信息处理
2013-08-03 20:05 1212<?xml version="1.0&qu ... -
基于契约优先来编写webservice
2013-08-03 18:40 1198开发流程: 1.先写schema ... -
通过Handler添加HEADER
2013-08-03 14:05 2021LogicHandler 只能获取SOAPBody的信息 ... -
SOAP异常处理
2013-08-03 14:00 986接口 package com.hqh.soap; imp ... -
深入SOAP发送消息的过程(SAAJ)
2013-07-28 18:54 2051SOAP结构体 SOAPMessage SOAPPa ... -
使用Transformer更新XML
2013-07-27 14:46 2748package com.hqh.stax; impo ... -
使用XMLStreamWriter写XML
2013-07-27 14:10 3993package com.hqh.stax; im ... -
使用java提供的XPATH处理xml
2013-07-27 13:10 958books.xml <?xml version=&q ... -
使用Stax处理XML
2013-07-27 10:57 1263java提供的XML处理 Stax处 ... -
使用JAXB完成XML与java对象的转换
2013-07-27 10:05 2117SAX 处理超大xml时使用 do ...
相关推荐
基于jax-ws 实现的web service client和server端的demo程序。 注:如果使用的是 myeclipse 时 server 部署到tomcat 启动的时候会报错 解决办法:找到myeclipse安装目录下的 plugins 目录里 查找 webservices-rt.jar,...
JAX-WS自学笔记 本人自学JAX-WS笔记和简单例子,文档标题结构如下: JAX-WS使用教程 1、JAX-WS概述 2、创建Web Service 2.1 从java开始 2.1.1 运行wsgen 2.1.2 生成的WSDL和XSD 2.1.3 目录结构 2.2 从WSDL...
JAX-WS 2.2 RI 所包含的JAR包集合,包含25个JAR包,列表如下: FastInoset.jar gmbal-api-only.jar ha-api.jar javax.annotation.jar javax.mail_1.4.jar jaxb-api.jar jaxb-impl.jar jaxb-xjc.jar jaxws-api...
亲测可用,Jax-ws所需要的JAR包,拷贝到tomcat安装路径的lib里,实现了webservice发布到tomcat,赞!
MyEclipse8_0中使用 JAX-WS 部署 WebService 实例 - 外衣 - 博客频道 - CSDN_NET.mht
The Java API for XML Web Services (JAX-WS) is a Java programming language API for creating web services, particularly SOAP services. JAX-WS is one of the Java XML programming APIs. It's a part of the ...
webService部署tomcat需要的jax-ws 的完整jar包
JAX-WS方式开发和部署webservice应用,JAX-WS方式开发和部署webservice应用,JAX-WS方式开发和部署webservice应用,JAX-WS方式开发和部署webservice应用,JAX-WS方式开发和部署webservice应用
JAX-WS2.0 API
Jax-WS的简单实例 Jax-WS的简单实例
javax.xml.ws.Service 报错需要的包,亲测可以用,直接下载在ide里buildpath一下就可以,四个jar包 ,整合了其他的jar所以配置简单
jax-ws webservice完整demo,包含所有jax-ws 2.2jar包。
使用 Eclipse JavaEE 开发 WebService 时,若选择手动创建原生的JAX-WS服务,需要导入此jar资源(教程详见我的博文https://blog.csdn.net/weixin_50604409/article/details/116399530)。 如果您同时装有 IntelliJ ...
JAX-WS不是一个孤立的框架,它依赖于众多其他的规范,本质上它由以下几部分组成 1.用来开发Web Services的Java API 2.用来处理Marshal/Unmarshal的XML Binding机制,JAX-WS2.0用JAXB2来处理Java Object与XML之间的映射,...
使用JAX-WS(JWS)发布WebService 使用myeclipse开发java的webservice的两种方式 方式一: (此方式只能作为调试,有以下bug:jdk1.6u17?以下编译器不支持以Endpoint.publish方式发布document方式的soap,必须在...
如果基于一个JAX-WS进行WebService开发,有很多教程,但是具体怎么更自动地生成一些文件,实现客户端与服务端的交互,都讲得不大清楚,为了让大家更方便地部署,我将服务端、客户端文件的生成与部署全过程以及测试...
JAX-WS 2.2 RI 所包含的JAR包集合,包含25个JAR包,列表如下: FastInoset.jar gmbal-api-only.jar ha-api.jar javax.annotation.jar javax.mail_1.4.jar jaxb-api.jar jaxb-impl.jar jaxb-xjc.jar jaxws-api...
rar中包含整个项目的源码和数据库生成脚本,采用jax-ws发布Web Service服务,支持java客户端和.Net客户端调用,数据库采用oracle10g,里面有创建数据库脚本文件createTable_Oracle10g.sql,由于Hibernate映射表中会...
NULL 博文链接:https://iamliming.iteye.com/blog/1399257