Web 服务描述语言 (WSDL) 1.0

合集下载

什么是WSDL

什么是WSDL

什么是WSDLWSDL是一种描述网络服务(network service)的XML格式,网络服务是能对面向文档类型的信息和面向过程的信息进行操作的端点(endpoint)的集合。

对操作和消息的描述是抽象性的,并在定义端点时,将消息和操作绑定到具体的网络协议和消息格式上。

WSDL是可扩展的,它允许对端点和端点间的消息进行描述,同时不去考虑具体的消息格式或者双方用于通讯的网络协议。

一简介随着通讯协议和消息格式在WEB中的标准化,以某种格式化的方法描述通讯变得越来越重要并且其实现的可能性也越来越大。

WSDL通过定义一套XML的语法来描述网络服务的方式满足了这种需求。

WSDL把网络服务定义成一个能交换消息的通讯端点集(communication collection)。

WSDL服务为分布式系统提供了帮助文档,同时该服务也可作为自动实现应用间通讯的解决方案。

一个WSDL文档将服务定义为一个网络端点的集合,或者说端口的集合。

在WSDL里面,端点及消息的抽象定义与它们具体的网络实现和数据格式绑定是分离的。

这样就可以重用这些抽象定义:消息,需要交换的数据的抽象描述;端口类型,操作的抽象集合。

针对一个特定端口类型的具体协议和数据格式规范构成一个可重用的绑定。

一个端口定义成网络地址和可重用的绑定的联接,端口的集合定义为服务。

因此一个WSDL文档在定义网络服务的时候使用如下的元素:类型–使用某种的类型系统(比如XSD)定义数据类型的容器消息–通讯数据抽象的有类型的定义操作–服务支持的动作的抽象描述端口类型–一个操作的抽象集合,该操作由一个或多个端点支持绑定–针对一个特定端口类型的具体的协议规范和数据格式规范端口–一个单一的端点,定义成一个绑定和一个网络地址的联接服务–相关的端点的集合我们可以注意到WSDL并没有引入一种新的类型语言,这一点非常重要。

为了描述消息的结构,需要具有丰富类型的系统,WSDL意识到了这种需求,因此它支持XML的schema 规范作为它的规范的类型系统。

WSDL文件结构详解

WSDL文件结构详解

wsdl文件结构分析WSDL (Web Services Description Language,Web服务描述语言)是一种XML Application,他将Web服务描述定义为一组服务访问点,客户端可以通过这些服务访问点对包含面向文档信息或面向过程调用的服务进行访问(类似远程过程调用)。

WSDL首先对访问的操作和访问时使用的请求/响应消息进行抽象描述,然后将其绑定到具体的传输协议和消息格式上以最终定义具体部署的服务访问点。

相关的具体部署的服务访问点通过组合就成为抽象的Web服务。

本文将详细讲解WSDL文档的结构,并分析每个元素的作用。

一:WSDL定义WSDL是一个用于精确描述Web服务的文档,WSDL文档是一个遵循WSDL XML模式的XML文档。

WSDL 文档将Web服务定义为服务访问点或端口的集合。

在 WSDL 中,由于服务访问点和消息的抽象定义已从具体的服务部署或数据格式绑定中分离出来,因此可以对抽象定义进行再次使用:消息,指对交换数据的抽象描述;而端口类型,指操作的抽象集合。

用于特定端口类型的具体协议和数据格式规范构成了可以再次使用的绑定。

将Web访问地址与可再次使用的绑定相关联,可以定义一个端口,而端口的集合则定义为服务。

一个WSDL文档通常包含7个重要的元素,即types、import、message、portType、operation、binding、 service元素。

这些元素嵌套在definitions 元素中,definitions是WSDL文档的根元素。

文章的下一部分将会详细介绍WSDL 的基本结构。

二:WSDL的基本结构--概述如第一部分最后描述的那样,一个基本的WSDL文档包含7个重要的元素。

下面将分别介绍这几个元素以及他们的作用。

WSDL 文档在Web服务的定义中使用下列元素:· Types - 数据类型定义的容器,它使用某种类型系统(一般地使用XML Schema中的类型系统)。

OracleEBS-WebService开发笔记

OracleEBS-WebService开发笔记

Configure
JDK1.6 安装JDK1.6,略
Tomcat5.5 1.解压Tomcat。
2.配置好JAVA环境变量。有两方法:
方法一:在系统环境变量,设置JAVA_HOME、CLASS_PATH变量。
在window的命令行,执行 SETX JAVA_HOME F:\ProgramFiles\WebServiceTools\Java\jdk1.6.0_25 /M SETX CLASSPATH .;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar; /M SETX PATH "%JAVA_HOME%\bin;%PATH%;" /M
Web Service For R12
PLSQL Deploy WebService Create the Package Create the WebService Deploy the WebService
Integration Repository
Oracle XML Gateway
Other Notes
Concept XML SOAP WSDL UDDI REST Web Service
Web Service For Axis1.4
Download Configure
JDK1.6 Tomcat5.5 Axis1.4 Test a SOAP Endpoint Test a JWS Endpoint Axis1.4 for Development Instant Deployment Custom Deployment RMI Cancel Deployment Handle Chain Transfer Object WSDL2Java

WSDL文档

WSDL文档

WSDL (Web Services Description Language,Web服务描述语言)是一种XML Application,他将Web服务描述定义为一组服务访问点,客户端可以通过这些服务访问点对包含面向文档信息或面向过程调用的服务进行访问(类似远程过程调用)。

WSDL首先对访问的操作和访问时使用的请求/响应消息进行抽象描述,然后将其绑定到具体的传输协议和消息格式上以最终定义具体部署的服务访问点。

相关的具体部署的服务访问点通过组合就成为抽象的Web服务。

本文将详细讲解WSDL文档的结构,并分析每个元素的作用。

一:WSDL定义WSDL是一个用于精确描述Web服务的文档,WSDL文档是一个遵循WSDL XML模式的XML文档。

WSDL 文档将Web服务定义为服务访问点或端口的集合。

在WSDL 中,由于服务访问点和消息的抽象定义已从具体的服务部署或数据格式绑定中分离出来,因此可以对抽象定义进行再次使用:消息,指对交换数据的抽象描述;而端口类型,指操作的抽象集合。

用于特定端口类型的具体协议和数据格式规范构成了可以再次使用的绑定。

将Web访问地址与可再次使用的绑定相关联,可以定义一个端口,而端口的集合则定义为服务。

一个WSDL文档通常包含7个重要的元素,即types、import、message、portType、operation、binding、service元素。

这些元素嵌套在definitions元素中,definitions是WSDL文档的根元素。

文章的下一部分将会详细介绍WSDL的基本结构。

二:WSDL的基本结构--概述如第一部分最后描述的那样,一个基本的WSDL文档包含7个重要的元素。

下面将分别介绍这几个元素以及他们的作用。

WSDL 文档在Web服务的定义中使用下列元素:Types - 数据类型定义的容器,它使用某种类型系统(一般地使用XML Schema中的类型系统)。

Message - 通信消息的数据结构的抽象类型化定义。

webservice执行原理和步骤

webservice执行原理和步骤

Web服务(Web Service)是一种基于Web的应用程序接口(API),它使用标准的HTTP协议进行通信,通过网络提供服务和交换数据。

Web服务的执行原理和步骤如下:1. 定义服务接口:首先,需要定义Web服务的接口,即确定服务提供的功能和方法。

这可以使用一种称为WSDL(Web Services Description Language)的XML语言来描述。

2. 发布服务:将定义好的服务接口发布到网络上,使其他应用程序可以访问。

这可以通过将WSDL文件部署到Web服务器上来实现。

3. 发现服务:其他应用程序可以通过查找和发现机制来找到已发布的Web服务。

这可以通过使用UDDI(Universal Description, Discovery, and Integration)注册表或其他服务目录来实现。

4. 绑定服务:一旦找到了所需的Web服务,应用程序需要与之建立连接。

这可以通过使用SOAP(Simple Object Access Protocol)协议来实现,SOAP是一种基于XML的协议,用于在网络上交换结构化的信息。

5. 调用服务:应用程序可以通过发送SOAP消息来调用Web 服务的方法。

SOAP消息包含了调用的方法名和参数,以及其他必要的信息。

6. 处理请求:Web服务接收到SOAP消息后,会解析消息并执行相应的方法。

方法的执行可能涉及到访问数据库、处理数据、调用其他服务等操作。

7. 返回结果:一旦方法执行完成,Web服务会将结果封装成SOAP消息并返回给调用方。

调用方可以解析SOAP消息并获取返回的结果。

8. 解绑服务:当不再需要使用Web服务时,应用程序可以断开与服务的连接。

这可以通过关闭连接或释放资源来实现。

总结起来,Web服务的执行原理和步骤包括定义服务接口、发布服务、发现服务、绑定服务、调用服务、处理请求、返回结果和解绑服务。

通过这些步骤,应用程序可以与Web服务进行通信并获取所需的功能和数据。

Web1.0、 Web2.0、Web3.0、Web4.0、Web5.0及Web6.0的涵义

Web1.0、 Web2.0、Web3.0、Web4.0、Web5.0及Web6.0的涵义

Web1.0、Web2.0、Web3.0、Web4.0、Web5.0及Web6.0的涵义一、Web1.0web1.0时代是一个群雄并起,逐鹿网络的时代,虽然各个网站采用的手段和方法不同,但第一代互联网有诸多共同的特征,表现在:1、web1.0基本采用的是技术创新主导模式,信息技术的变革和使用对于网站的新生与发展起到了关键性的作用。

新浪的最初就是以技术平台起家,搜狐以搜索技术起家,腾讯以即时通讯技术起家,盛大以网络游戏起家,在这些网站的创始阶段,技术性的痕迹相当之重。

2、web1.0的盈利都基于一个共通点,即巨大的点击流量。

无论是早期融资还是后期获利,依托的都是为数众多的用户和点击率,以点击率为基础上市或开展增值服务,受众群众的基础,决定了盈利的水平和速度,充分地体现了互联网的眼球经济色彩。

3、web1.0的发展出现了向综合门户合流现象,早期的新浪与搜狐、网易等,继续坚持了门户网站的道路,而腾讯、MSN、GOOGLE等网络新贵,都纷纷走向了门户网络,尤其是对于新闻信息,有着极大的、共同的兴趣。

这一情况的出现,在于门户网站本身的盈利空间更加广阔,盈利方式更加多元化,占据网站平台,可以更加有效地实现增值意图,并延伸由主营业务之外的各类服务。

4、web1.0的合流同时,还形成了主营与兼营结合的明晰产业结构。

新浪以新闻+广告为主,网易拓展游戏,搜狐延伸门户矩阵,各家以主营作为突破口,以兼营作为补充点,形成拳头加肉掌的发展方式。

5、web1.0不以html 为言,在1.0时代,动态网站已经广泛应用,比如论坛等。

二、Web2.0Web2.0,是相对Web1.0(2003年以前的互联网模式)的新的一类互联网应用的统称,是一次从核心内容到外部应用的革命。

由Web1.0单纯通过网络浏览器浏览html网页模式向内容更丰富、联系性更强、工具性更强的Web2.0互联网模式的发展已经成为互联网新的发展趋势。

“Web 2.0”的概念开始于一个会议中,展开于O’Reilly公司和MediaLive国际公司之间的头脑风暴部分。

WEBSERVICE简介

WEBSERVICE简介Web ServiceWeb Service是一种构建应用程序的普遍模型,可以在任何支持网络通信的操作系统中实施运行;它是一种新的we b 应用程序分支,是自包含、自描述、模块化的应用,可以发布、定位、通过web调用。

Web Service是一个应用组件,它逻辑性的为其他应用程序提供数据与服务.各应用程序通过网络协议和规定的一些标准数据格式(Http,XML,So ap)来访问Web Service,通过Web Service内部执行得到所需结果.Web Service可以执行从简单的请求到复杂商务处理的任何功能。

一旦部署以后,其他Web Service应用程序可以发现并调用它部署的服务。

技术和规则在构建和使用Web Service时,主要用到以下几个关键的技术和规则:1.XML:描述数据的标准方法.2.SOAP:表示信息交换的协议.3.WSDL:Web服务描述语言.4.UDDI(Universal Description, Discovery and Integration):通用描述、发现与集成,它是一种独立于平台的,基于XML语言的用于在互联网上描述商务的协议。

实际上,WebService的主要目标是跨平台的可互操作性。

为了达到这一目标,WebService完全基于XML(可扩展标记语言)、XSD(XMLSchema)等独立于平台、独立于软件供应商的标准,是创建可互操作的、分布式应用程序的新平台。

由此可以看出,在以下三种情况下,使用WebService会带来极大的好处。

XML可扩展标记语言(Extensible Markup Language, XML) ,用于标记电子文件使其具有结构性的标记语言,可以用来标记数据、定义数据类型,是一种允许用户对自己的标记语言进行定义的源语言。

XML是标准通用标记语言(SG ML) 的子集,非常适合Web 传输。

XML 提供统一的方法来描述和交换独立于应用程序或供应商的结构化数据。

WebService接口的几种调用方式--wsdl文件类型

WebService接⼝的⼏种调⽤⽅式--wsdl⽂件类型⾸先⽐如查询到的⼀个wsdl⽂件内容如下:<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions targetNamespace="http://198.168.0.88:6888/ormrpc/services/EASLogin" xmlns:apachesoap="/xml-soap" xmlns:impl="http://198.168.0.88:6888/ormrpc/services/EASLogin" xmlns:intf="http://198.168.0.88:68 <!--WSDL created by Apache Axis version: 1.4Built on Apr 22, 2006 (06:55:48 PDT)--><wsdl:types><schema targetNamespace="urn:client" xmlns="/2001/XMLSchema"><import namespace="/soap/encoding/"/><complexType name="WSContext"><sequence><element name="dbType" type="xsd:int"/><element name="dcName" nillable="true" type="xsd:string"/><element name="password" nillable="true" type="xsd:string"/><element name="sessionId" nillable="true" type="xsd:string"/><element name="slnName" nillable="true" type="xsd:string"/><element name="userName" nillable="true" type="xsd:string"/></sequence></complexType></schema></wsdl:types><wsdl:message name="logoutResponse"><wsdl:part name="logoutReturn" type="xsd:boolean"></wsdl:part></wsdl:message><wsdl:message name="loginResponse"><wsdl:part name="loginReturn" type="tns1:WSContext"></wsdl:part></wsdl:message><wsdl:message name="loginRequest"><wsdl:part name="userName" type="xsd:string"></wsdl:part><wsdl:part name="password" type="xsd:string"></wsdl:part><wsdl:part name="slnName" type="xsd:string"></wsdl:part><wsdl:part name="dcName" type="xsd:string"></wsdl:part><wsdl:part name="language" type="xsd:string"></wsdl:part><wsdl:part name="dbType" type="xsd:int"></wsdl:part><wsdl:part name="authPattern" type="xsd:string"></wsdl:part></wsdl:message><wsdl:message name="loginResponse1"><wsdl:part name="loginReturn" type="tns1:WSContext"></wsdl:part></wsdl:message><wsdl:message name="logoutRequest"><wsdl:part name="userName" type="xsd:string"></wsdl:part><wsdl:part name="slnName" type="xsd:string"></wsdl:part><wsdl:part name="dcName" type="xsd:string"></wsdl:part><wsdl:part name="language" type="xsd:string"></wsdl:part></wsdl:message><wsdl:message name="loginResponse2"><wsdl:part name="loginReturn" type="tns1:WSContext"></wsdl:part></wsdl:message><wsdl:message name="loginRequest1"><wsdl:part name="userName" type="xsd:string"></wsdl:part><wsdl:part name="password" type="xsd:string"></wsdl:part><wsdl:part name="slnName" type="xsd:string"></wsdl:part><wsdl:part name="dcName" type="xsd:string"></wsdl:part><wsdl:part name="language" type="xsd:string"></wsdl:part><wsdl:part name="dbType" type="xsd:int"></wsdl:part></wsdl:message><wsdl:message name="loginByLtpaTokenRequest"><wsdl:part name="userName" type="xsd:string"></wsdl:part><wsdl:part name="ltpaToken" type="xsd:string"></wsdl:part><wsdl:part name="slnName" type="xsd:string"></wsdl:part><wsdl:part name="dcName" type="xsd:string"></wsdl:part><wsdl:part name="language" type="xsd:string"></wsdl:part><wsdl:part name="dbType" type="xsd:int"></wsdl:part></wsdl:message><wsdl:message name="loginRequest2"><wsdl:part name="userName" type="xsd:string"></wsdl:part><wsdl:part name="password" type="xsd:string"></wsdl:part><wsdl:part name="slnName" type="xsd:string"></wsdl:part><wsdl:part name="dcName" type="xsd:string"></wsdl:part><wsdl:part name="language" type="xsd:string"></wsdl:part><wsdl:part name="dbType" type="xsd:int"></wsdl:part><wsdl:part name="authPattern" type="xsd:string"></wsdl:part><wsdl:part name="isEncodePwd" type="xsd:int"></wsdl:part></wsdl:message><wsdl:message name="loginByLtpaTokenResponse"><wsdl:part name="loginByLtpaTokenReturn" type="tns1:WSContext"></wsdl:part></wsdl:message><wsdl:portType name="EASLoginProxy"><wsdl:operation name="logout" parameterOrder="userName slnName dcName language"><wsdl:input message="impl:logoutRequest" name="logoutRequest"></wsdl:input><wsdl:output message="impl:logoutResponse" name="logoutResponse"></wsdl:output></wsdl:operation><wsdl:operation name="login" parameterOrder="userName password slnName dcName language dbType authPattern"> <wsdl:input message="impl:loginRequest" name="loginRequest"></wsdl:input><wsdl:output message="impl:loginResponse" name="loginResponse"></wsdl:output></wsdl:operation><wsdl:operation name="login" parameterOrder="userName password slnName dcName language dbType"><wsdl:input message="impl:loginRequest1" name="loginRequest1"></wsdl:input><wsdl:output message="impl:loginResponse1" name="loginResponse1"></wsdl:output></wsdl:operation><wsdl:operation name="login" parameterOrder="userName password slnName dcName language dbType authPattern isEncodePwd"><wsdl:input message="impl:loginRequest2" name="loginRequest2"></wsdl:input><wsdl:output message="impl:loginResponse2" name="loginResponse2"></wsdl:output></wsdl:operation><wsdl:operation name="loginByLtpaToken" parameterOrder="userName ltpaToken slnName dcName language dbType"><wsdl:input message="impl:loginByLtpaTokenRequest" name="loginByLtpaTokenRequest"></wsdl:input><wsdl:output message="impl:loginByLtpaTokenResponse" name="loginByLtpaTokenResponse"></wsdl:output></wsdl:operation></wsdl:portType><wsdl:binding name="EASLoginSoapBinding" type="impl:EASLoginProxy"><wsdlsoap:binding style="rpc" transport="/soap/http"/><wsdl:operation name="logout"><wsdlsoap:operation soapAction=""/><wsdl:input name="logoutRequest"><wsdlsoap:body encodingStyle="/soap/encoding/" namespace="" use="encoded"/> </wsdl:input><wsdl:output name="logoutResponse"><wsdlsoap:body encodingStyle="/soap/encoding/" namespace="http://198.168.0.88:6888/ormrpc/services/EASLogin" use="encoded"/> </wsdl:output></wsdl:operation><wsdl:operation name="login"><wsdlsoap:operation soapAction=""/><wsdl:input name="loginRequest"><wsdlsoap:body encodingStyle="/soap/encoding/" namespace="" use="encoded"/> </wsdl:input><wsdl:output name="loginResponse"><wsdlsoap:body encodingStyle="/soap/encoding/" namespace="http://198.168.0.88:6888/ormrpc/services/EASLogin" use="encoded"/> </wsdl:output></wsdl:operation><wsdl:operation name="login"><wsdlsoap:operation soapAction=""/><wsdl:input name="loginRequest1"><wsdlsoap:body encodingStyle="/soap/encoding/" namespace="" use="encoded"/> </wsdl:input><wsdl:output name="loginResponse1"><wsdlsoap:body encodingStyle="/soap/encoding/" namespace="http://198.168.0.88:6888/ormrpc/services/EASLogin" use="encoded"/> </wsdl:output></wsdl:operation><wsdl:operation name="login"><wsdlsoap:operation soapAction=""/><wsdl:input name="loginRequest2"><wsdlsoap:body encodingStyle="/soap/encoding/" namespace="" use="encoded"/> </wsdl:input><wsdl:output name="loginResponse2"><wsdlsoap:body encodingStyle="/soap/encoding/" namespace="http://198.168.0.88:6888/ormrpc/services/EASLogin" use="encoded"/> </wsdl:output></wsdl:operation><wsdl:operation name="loginByLtpaToken"><wsdlsoap:operation soapAction=""/><wsdl:input name="loginByLtpaTokenRequest"><wsdlsoap:body encodingStyle="/soap/encoding/" namespace="" use="encoded"/> </wsdl:input><wsdl:output name="loginByLtpaTokenResponse"><wsdlsoap:body encodingStyle="/soap/encoding/" namespace="http://198.168.0.88:6888/ormrpc/services/EASLogin" use="encoded"/> </wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="EASLoginProxyService"><wsdl:port binding="impl:EASLoginSoapBinding" name="EASLogin"><wsdlsoap:address location="http://198.168.0.88:6888/ormrpc/services/EASLogin"/></wsdl:port></wsdl:service></wsdl:definitions>⼀般有⼏种⽅式调⽤此接⼝:⽅式⼀:通过wsdl⽂件或者链接使⽤相关IDE软件⽣成Java⽂件这种⽅式⽐较累赘,不做推荐,使⽤IDE软甲即可完成⽅式⼆:使⽤apache的动态代理⽅式实现话不多说,直接上代码:import .URL;import space.QName;import org.apache.axis.client.Call;import org.apache.axis.client.Service;public class UsingDII {public static void main(String[] args) {try {int a = 100, b=60; // 对应的targetNamespaceString endPoint = "http://198.168.0.88:6888/ormrpc/services/EASLogin";Service service = new Service();Call call = (Call)service.createCall();call.setOperationName(new QName(endPoint,"EASLogin"));call.setTargetEndpointAddress(new URL(endPoint)); // a,b 调⽤此⽅法的参数String result = (String)call.invoke(new Object[]{new Integer(a),new Integer(b)});System.out.println("result is :"+result);} catch (Exception e) {e.printStackTrace();}}}⽅式三:使⽤Dynamic Proxy动态代理import .URL;import javax.xml.*;public class UsingDP {public static void main(String[] args) {try {int a = 100, b=60;String wsdlUrl = "http://198.168.0.88:6888/ormrpc/services/EASLogin?wsdl";String nameSpaceUri = "http://198.168.0.88:6888/ormrpc/services/EASLogin";String serviceName = "EASLoginProxyService";String portName = "EASLogin";ServiceFactory serviceFactory = ServiceFactory.newInstance();Service service = serviceFactory.createService(new URL(wsdlUrl),new QName(nameSpaceUri,serviceName)); // 返回值是⾃⼰封装的类AddFunctionServiceIntf adsIntf = (AddFunctionServiceIntf)service.getPort(new QName(nameSpaceUri,portName),AddFunctionServiceIntf.class); System.out.println("result is :"+adsIntf.addInt(a, b));} catch (Exception e) {e.printStackTrace();}}}⽅式四:使⽤httpclient⽅式参考:直接上代码:import java.io.ByteArrayInputStream;import java.io.IOException;import java.io.InputStream;import java.util.List;import mons.httpclient.HttpClient;import mons.httpclient.methods.InputStreamRequestEntity;import mons.httpclient.methods.PostMethod;import mons.httpclient.methods.RequestEntity;import org.apache.log4j.Logger;import org.dom4j.Document;import org.dom4j.io.SAXReader;// 这⾥引得依赖包的话需要⾃⼰找了下⾯地址可以找到//https:///public static InputStream postXmlRequestInputStream(String requestUrl, String xmlData) throws IOException{PostMethod postMethod = new PostMethod(requestUrl);byte[] b = xmlData.getBytes("utf-8");InputStream is = new ByteArrayInputStream(b, 0, b.length);RequestEntity re = new InputStreamRequestEntity(is, b.length, "text/xml;charset=utf-8");postMethod.setRequestEntity(re);HttpClient httpClient = new HttpClient();httpClient.getParams().setAuthenticationPreemptive(true);httpClient.getHostConfiguration().setProxy(CommonPptsUtil.get("PROXY_HOST"), Integer.valueOf(CommonPptsUtil.get("PROXY_PORT")));int statusCode = httpClient.executeMethod(postMethod);logger.debug("responseCode:"+statusCode);if (statusCode != 200) {return null;}return postMethod.getResponseBodyAsStream();}public static void main(String[] args) {String reqJsonStr = "{\"workId\":\"20171018161622\",\"status\":\"201\",\"startTime\":\"2017-10-18 16:16:22\"}";String xmlData = "<soapenv:Envelope xmlns:soapenv=\"/soap/envelope/\" xmlns:ser=\"/\"><soapenv:Header/><soapenv:Body><ser:statusWriteBack><jsonString>" + "{\"workId\":\"314\",\"orderId\":\"5207675\",\"longitude\":\"104.068310\",\"latitude\":\"30.539503\",\"sendTime\":\"2019-08-13 08:38:45\",\"servicePerName\":\"于xx\",\"servicePerPhone\":\"184xxxx7680\"}"+ "</jsonString></ser:statusWriteBack></soapenv:Body></soapenv:Envelope>";String url = "http://xx.xxx.246.88:7103/avs/services/CCService?wsdl";SAXReader reader = new SAXReader();String result = "";try {InputStream in = postXmlRequestInputStream(url,xmlData);if(in!=null){Document doc = reader.read(in);result = doc.getRootElement().element("Body").element("statusWriteBackResponse").element("return").getText();logger.debug("result:"+result);}} catch (Exception e) {logger.error("error:",e);e.printStackTrace();}}}CommonPptsUtil://就是获取配置⽂件⾥的代理信息import mons.configuration.ConfigurationException;import mons.configuration.PropertiesConfiguration;import mons.configuration.reloading.FileChangedReloadingStrategy;import org.apache.log4j.Logger;/*** 通⽤属性⽂件⼯具类** @author y.c**/public class CommonPptsUtil {private static final Logger logger = Logger.getLogger(CommonPptsUtil.class);private static final String CONFIG_FILE = "common.properties";private static PropertiesConfiguration ppts;static {try {ppts = new PropertiesConfiguration(CONFIG_FILE);ppts.setReloadingStrategy(new FileChangedReloadingStrategy());} catch (ConfigurationException e) {logger.error("⽂件【common.properties】加载失败!");ppts = null;}}/*** 获取属性值** @param key* @return属性值*/public static String get(String key) {if (ppts == null) {return null;}return ppts.getString(key);}}⽅式五:使⽤CXF动态调⽤webservice接⼝代码如下:参考:package cxfClient;import org.apache.cxf.endpoint.Endpoint;import space.QName;import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;import org.apache.cxf.service.model.BindingInfo;import org.apache.cxf.service.model.BindingOperationInfo;public class CxfClient {public static void main(String[] args) throws Exception {String url = "http://localhost:9091/Service/SayHello?wsdl";String method = "say";Object[] parameters = new Object[]{"我是参数"};System.out.println(invokeRemoteMethod(url, method, parameters)[0]);}public static Object[] invokeRemoteMethod(String url, String operation, Object[] parameters){JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();if (!url.endsWith("wsdl")) {url += "?wsdl";}org.apache.cxf.endpoint.Client client = dcf.createClient(url);//处理webService接⼝和实现类namespace不同的情况,CXF动态客户端在处理此问题时,会报No operation was found with the name的异常Endpoint endpoint = client.getEndpoint();QName opName = new QName(endpoint.getService().getName().getNamespaceURI(),operation);BindingInfo bindingInfo= endpoint.getEndpointInfo().getBinding();if(bindingInfo.getOperation(opName) == null){for(BindingOperationInfo operationInfo : bindingInfo.getOperations()){if(operation.equals(operationInfo.getName().getLocalPart())){opName = operationInfo.getName();break;}}}Object[] res = null;try {res = client.invoke(opName, parameters); } catch (Exception e) {e.printStackTrace();}return res;}}。

如何看懂一个WSDL文档

如何看懂一个WSDL文档WSDL 指网络服务描述语言 (Web Services Description Language)。

一个WSDL文档是一个服务的描述,它描述了:服务名,服务地址,服务能用什么协议访问,服务有哪些方法,每个方法有几部分参数,每个参数的类型。

在一个WSDL文档中,你最经常看到的元素前缀会有wsdl、soap、xsd。

当然这些前缀是与命名空间URI对应的,前缀是可以自己定义的,或许与此不同,但大都这么定义。

WSDL在设计时,充分考虑了,各个元素模块的重用(好像一个类中定义了一些方法,可被不同方法共同调用)如:wsdl:binding、wsdl:portType、wsdl:message,你定义的这个元素可能被几个地方引用到。

所以WSDL设计者把它设计的够精简、灵活。

下面我基于WSDL 1.2 语法分别对三个命名空间的经常用到的元素解释一下:最好从下往上看//文档的根元素,表示这是一个服务的定义,在此定义中默认的名字空间URI 为“http://axisversion.sample”.<wsdl:definitions xmlns:axis2="http://axisversion.sample"xmlns:mime="/wsdl/mime/"xmlns:ns0="http://axisversion.sample/xsd"xmlns:soap12="/wsdl/soap12/"xmlns:http="/wsdl/http/"xmlns:ns1="http://org.apache.axis2/xsd"xmlns:xs="/2001/XMLSchema"xmlns:soap="/wsdl/soap/"xmlns:wsdl="/wsdl/"targetNamespace="http://axisversion.sample"><wsdl:documentation>This service is to get the running Axis version</wsdl:documentation>//为它表示所有消息中能使用的基本元素类型,如一个方法三个参数的其中一个参数的类型。

webServices安全验证方案

一、使用WSE实现Web Serivices安全验证WSE3.0全称是Web Services Enhancements3.0。

是微软针对Web Service推出的安全实现平台,包括为了实现安全认证和加密特定的类库。

WSE3.0的很多安全实现方式都能在WCF 框架里找到影子。

WebSerivice 2.0 支持WS-I Basic Profile 1.1 和SOAP 1.2。

这意味着,它支持XML 1.0、XML 架构定义(XSD)、Web 服务描述语言(WSDL)、SOAP 1.1、SOAP 1.2 以及编译时的基本配置文件一致性验证。

WSE 3.0 通过提供对某些更高级的WS-* 协议的支持,来补充WebSerivice 2.0 的功能。

二、使用SoapHeader实现Web Serivices安全验证在调用Web Serivices时,往往需要身份验证,使得通过验证的用户才能调用你Web Serivices 中的方法.当然你可以通过将参数添加到每个需要自定义身份验证方案的Web services方法中去,这需要花费很大的精力.IssueVision 中使用了非常常用而且有效便捷的方法-----使用SoapHeader来实现自定义身份验证数据的传递.SoapHeader提供了一种方法,用于将数据传递到Web services方法或从Web services 方法传递数据,条件是该数据不直接与Web services 方法的主功能相关. 你不用将参数添加到每个需要自定义身份验证方案的Web services 方法,而可以将引用从SoapHeader派生的类的SoapHeaderAttribute应用于每个Web services 方法。

从SoapHeader派生的类的实现处理该自定义身份验证方案. IssueVision 就是利用SoapHeader的这种能力来实现自定义身份验证数据传递的.例:看demoSoapHeader缺点:上面所说的是如何保证Web Service的授权使用,但是在实际使用中,客户端传输到Web Service的用户名和密码都是以需要进行加密。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Web服务描述语言(WSDL) 1.02000年9月25日作者(按姓氏字母顺序排列):Erik Christensen,MicrosoftFrancisco Curbera,IBMGreg Meredith,MicrosoftSanjiva Weerawarana,IBM版权所有© 2000 Ariba,International Business Machines Corporation,Microsoft摘要WSDL 是一种 XML 格式,用于将网络服务描述为一组端点,这些端点对包含面向文档信息或面向过程信息的消息进行操作。

这种格式首先对操作和消息进行抽象描述,然后将其绑定到具体的网络协议和消息格式上以定义端点。

相关的具体端点即组合成为抽象端点(服务)。

可以对 WSDL 进行扩展,这样无论通信时使用何种消息格式或网络协议,都可以对端点及其消息进行描述。

但是,本文档中所述的绑定只涉及有关如何将 WSDL 与 SOAP 1.1、HTTP GET/POST 和 MIME 一起使用的问题。

此版本的 WSDL 语言尚处于初步阶段,没有提供框架来说明端点的撰写过程。

描述这些约定的完整框架应包含撰写服务的方式和表达服务行为的方式(即相应的用于发送和接收消息的规则)。

服务的撰写应满足两个要求:(1) 确保类型的安全性,(2) 允许在运行时通过交换和绑定服务引用来传递引用。

后面的这一条对于在运行期协商约定以及捕获引用服务和代理服务的行为至关重要。

WSDL 规范的作者希望及时发布 WSDL 的修订版和/或一些附加文档,包括:(1) 撰写服务的框架;(2) 描述服务行为的框架。

状态本草案介绍了 Ariba、IBM 和 Microsoft 当前在服务描述方面的一些思路。

它对 NASSL、SCL 和 SDL(有关这方面的早期建议)中的一些概念进行了整理合并。

目录1.简介2.服务定义o文档结构o类型o消息o端口类型o绑定o端口o服务3.SOAP 绑定o SOAP 示例o SOAP 绑定如何扩展 WSDLo soap:bindingo soap:operationo soap:bodyo soap:faulto soap:headero soap:address4.HTTP GET 和 POST 绑定o HTTP GET/POST 示例o HTTP GET/POST 绑定如何扩展 WSDLo http:addresso http:bindingo http:operationo http:urlEncodedo http:urlReplacement5.MIME 绑定o MIME 绑定示例o MIME 绑定如何扩展 WSDLo mime:contento mime:multipartRelatedo soap:bodyo mime:mimeXml6.参考资料o有关 URI 的说明o WSDL 示例的线上格式o扩展性元素的位置o架构简介由于通信协议和消息格式在 Web 社区中已经过标准化,因而有可能以某种结构化的方式对通信加以描述,而且实现这一点也显得日益重要。

WSDL 定义了一种XML 语法,将网络服务描述为能够进行消息交换的通信端点的集合,从而满足了这种需求。

WSDL 服务定义为分布式系统提供了文档,并且可用于自动执行应用程序通信中所涉及的细节。

WSDL 文档将服务定义为网络端点或端口的集合。

在 WSDL 中,由于端点和消息的抽象定义已从具体的网络部署或数据格式绑定中分离出来,因此可以对抽象定义进行再次使用:消息,指对交换数据的抽象描述;而端口类型,指操作的抽象集合。

用于特定端口类型的具体协议和数据格式规范构成了可以再次使用的绑定。

将网络地址与可再次使用的绑定相关联,可以定义一个端口,而端口的集合则定义为服务。

因此,WSDL 文档在网络服务的定义中使用下列元素:∙Types - 数据类型定义的容器,它使用某种类型系统(如 XSD)。

∙Message - 通信数据的抽象类型化定义。

∙Operation - 对服务所支持的操作的抽象描述。

∙Port Type - 操作的抽象集合,这些操作由一个或多个端点支持。

∙Binding - 特定端口类型的具体协议和数据格式规范。

∙Port - 定义为绑定和网络地址组合的单个端点。

∙Service - 相关端点的集合。

将在第二节中对这些元素进行详细说明。

应该注意的是,WSDL 并没有引入新的类型定义语言。

虽然 WSDL 知道,要描述消息格式需要丰富的类型系统,并且它也支持“XML 架构规范(XSD)”作为其标准类型系统,但是,由于不可能只用一种类型系统语法来描述现在和将来的所有消息格式,因此 WSDL 允许通过扩展来使用其它类型定义语言。

此外,WSDL 还定义了通用的绑定机制。

通过该机制可使特定的协议、数据格式或结构与抽象的消息、操作或端点相关联。

该机制还允许对抽象定义进行再次使用。

虽然本文档定义了上述语言扩展,但这些扩展均位于核心服务定义框架的上部。

所以一定能将 WSDL 与其它绑定扩展一起使用。

WSDL文档示例下例是一个提供股票报价的简单服务的 WSDL 定义。

该服务支持名为GetLastTradePrice 的单一操作,这个操作是通过在 HTTP 上运行 SOAP 1.1 协议来实现的。

该请求接受一个类型为字符串的 ticker 符号,并返回类型为浮点数的价格。

有关此定义中所用元素的详细说明,请参见第 2 节(核心语言)和第 3 节(SOAP 绑定)。

示例 1 通过 HTTP 运行的 SOAP 1.1 请求/响应<?xml version="1.0"?><definitions name="StockQuote"targetN amespace="/stockquote.wsdl"xmlns:tns="/stockquote.wsdl"xmlns:xsd1="/stockquote.xsd"xmlns:soap="/wsdl/soap/"xmlns="/wsdl/"><types><schema targetNamespace="/stockquote.xsd"xmlns="/1999/XMLSchema"><element name="TradePriceR equest"><complexType><all><element name="tickerSymbol" type="string"/></all></complexType></element><element name="TradePrice"><complexType><all><element name="price" type="float"/></all></complexType></element></schema></types><message name="GetLastTradePriceInput"><part name="body" element="xsd1:TradePrice"/></message><message name="GetLastTradePriceOutput"><part name="body" element="xsd1:TradePriceResult"/></message><portType name="StockQuotePortType"><oper ation name="GetLastTradePr ice"><input message="tns:GetLastTradePriceInput"/><output message="tns:GetLastTradePriceOutput"/></operation></portType><binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType"> <soap:binding style="document" transport="/soap/http"/> <oper ation name="GetLastTradePr ice"><soap:operation soapAction="/GetLastTradePr ice"/><input><soap:body use="literal" namespace="/stockquote.xsd"encodingStyle="/soap/encoding/"/> </input><output><soap:body use="literal" namespace="/stockquote.xsd"encodingStyle="/soap/encoding/"/></output></operation></binding><service name="StockQuoteService"><documentation>我的第一次服务</documentation><port name="StockQuotePort" binding="tns:StockQuoteBinding"><soap:address location="/stockquote"/></port></service></definitions>标记规则1. 本文档中的关键字“MUST”、“MUST NOT”、“REQUIRED”、“SHALL”、“SHALL NOT”、“SHOULD”、“SHOULD NOT”、“RECOMMENDED”、“MAY”和“OPTIONAL”按照 RFC-2119中的说明进行解释。

相关文档
最新文档