`
holdbelief
  • 浏览: 707515 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

WSDL学习笔记1——WSDL支持的4种消息交换方式

阅读更多

    WSDl定义了4种操作类型,其中请求-响应是最普通的操作类型:

 

 

类型 定义
     One-way      此操作可接受消息,但不会返回响应。
     Request-response      此操走可接受一个请求并会返回一个响应
     Solicit-response      此操作可发送一个请求,并会等待一个响应。
     Notification      此操作可发送一条消息,但不会等待响应。

 

   1、One - way 操作

 

    一个one - way 操作的例子:

 

        <message name = "newTermValues">
                <part name = "term" type = "xs:string"/>
                <part name = "value" type = "xs:string">
        </message>                             

        <portType name = "glossaryTerms">
                <operation name = "setTerm">
                        <input name = "newTerm" message = "newTermValues"/>
                </operation>
        </portType>
 

    在这个例子中, 端口 “glossaryTerms” 定义了一个名为 “setTerm” 的 one-way 操作。

    这个 “setTerm” 操作可接受新术语表项目消息的输入, 这些消息使用一条名为 “newTermValues” 的消息, 此消息带有输入

    参数 “term” 和 “value”。不过, 没有为这个操作定义任何输出。

 

 

    2、Request - Response 操作

 

    一个 request-response 操作的例子:

 

        <message name = "getTermRequest">
                <part name = "term" type = "xs:string">
        </message>                             
        <message name = "getTermResponse">
                <part name = "value" type = "xs:string"/>
        </message>

        <portType name = "glossaryTerms">
                <operation name = "getTerm">
                        <input message = "getTermRequest"/>
                        <output message = "getTermResponse"/>
                </operation>
        </portType>

 

    在这个例子中, 端口 “glossaryTerms” 定义了一个名为 “getTerm” 的 request-response 操作。

    “getTerm” 操作会请求一个名为 “getTermRequest” 的输入消息, 此消息带有一个名为 “term” 的参数, 并将返回一个名为

    “getTermResponse” 的输出消息, 此消息带有一个名为 “value” 的参数。

 

    《JAVA WebService》一书中, P88页:

    5.2.5 <portType> Element

 

    The <portType> element specifies a subset of operations supported for an endpoint of a web service. In a

    sense, a <portType> element provides a unique identified to a group of actions that can be executed at a

    single endpoint.

 

    The <operation> element represents an operation. This element is an abstract definition of an action

    supported by a web service. A WSDL <operation> element is analogous to a Java method definition. A WSDL

    operation can have input and output messages as part of its action. The <operation> tag defines the name

    of the action by using a name attribute, defines the input message by the <input> subelement, and defines

    the output message by the <output> subelement. The <input> and <output> elements reference

    <message> elements defined in the same WSDL document or an imported one. A <message> element can

    represent a request, response, or a fault.

 

    Continuing with the Z39.50 ASN.1 sample, the WSDL file defines a single <portType> element:

 

    <portType name = "ez3950PortTypes">

 

    This element declares that this endpoint has a set of operations that jointly referenced as ez3950PortTypes.

    The following lines define the <operation> elements for this <portType>:

 

<portTyle>
<!-- Request-response Operations (client initiated) -->
        <operation name = "iniit">
                <input message = "initRequest"/>
                <output message = "initResponse"/>
        </operation>
        <operation name = "search">
                <input message="searchRequest"/>
                <output message="searchResponse"/>
        </operation>
        <operation name="present">
                <input message="presentRequest"/>
                <output message="presentResponse"/>
        </operation>
        <operation name="sort">
                <input message="sortRequest"/>
                <output message="sortResponse"/>
        </operation>
        <operation name="scan">
                <input message="scanRequest"/>
                <output message="scanResponse"/>
        </operation>
        <operation name="delete">
                <input message="deleteRequest"/>
                <output message="deleteResponse"/>
        </operation>
        <operation name="resourceReport">
                <input message="resourceReportRequest"/>
                <output message="resourceReportResponse"/>
        </operation>
        <operation name="extendedServices">
                <input message="extendedServicesRequest"/>
                <output message="extendedServicesResponse"/>
        </operation>
        <operation name="close">
                <output message="close"/>
                <input message="close"/>
        </operation>

<!-- Solicit-response Operation (Server initiated) -->
        <operation name = "accessControl">
                <output message = "accessControlResponse"/>
                <input message = "accessControlRequest"/>
        </operation>
        <operation name = "resourceControl">
                <output message="resourceControlResponse"/>
                <input message="resourceControlRequest"/>
        </operation>
        <operation name="close">
                <output message="close"/>
                <input message="close"/>
        </operation>

<!-- Notification Operations (Server initiated) -->
        <operation name = "segmenty">
                <output message = "segmentRequest"/>
        </operation>

<!-- One-way Operations (Client initiated) -->
        <operation name = "triggerResourceControl">
                <input message = "triggerResourceControlRequest"/>
        </operation>
</portType>

 

    These <operation> elements are grouped according to their behavior. When an operation is defined in a

    WSDL document, it is made to be abstract; it is purely an operation definition, but how that operation is

    mapped to a real function is defined later (i.e., the operation can behave in a number of different ways

    depending on the actual definition). The WSDL specification defines the following behavioral patterns as

    transmission primitives:

 

  •   Request-response
  •   Solicit-response
  •   One-way
  •   Notification

    First, the operation can follow a request-response model, in which a web service client invokes a request

    and expects to receive a synchronous response message. This model is defined by the presence of both

    <input> and <output> elements. The <input> element must appear before the <output> element. This order

    indicates that the operation first accepts an input message (reqeust) and then sends an output message

    (response). This model is similar to a normal procedure call, in which the calling method blocks until the called

    method returns its result.

 

    Second, the operation can follow a solicit-response model, in which the web service solicits a response from

    the client, expecting to receive a response. This model is defined as having both <input> and <output>

    elements. The <output> element must appear before the <input> element. This order indicates that the

    operation first sends an output message (solicit) and then receives an input message (response).

 

    Third, the operation can be a one-way invocation, in which the web sevice client sends a message to the

    web service without expecting to receive a response. This model is defined by a single <input> message

    with no <output> message. This model indicates that the operation receives input messages (one-way

    invocation), but doesn't deliver a response to the client.

 

    Fourth, the operation can be a notification, in which the web services sends a one-way message to the client

    without expecting a response. This model is defined by a single <output> message and no <input>

    message. It indicates that the operation sends output messages asynchronously; i.e., the messages are not

    in response to a request, but can be sent at any time. The operation doesn't expect a response to the

    messages it sends.

 

    annotate:

    For the request-response and solicit-response models, an optional <fault> element can be
    included. This element refers to another message. A <fault> message will be transmitted
    if any processing, system, or application errors occur. The <fault> message is delivered to
    the client in a request-response and to the web service in the solicit-response model.

 

    The value assigned to the name attribute of each <operation> element must be unique within the scope of

    the <portType>, not just the <operation>. The value assigned to the message attrubute of an <input> or

    <output> element must match one of the names of the <message> elements defined in the same WSDL or

    in an imported one.

 

分享到:
评论
1 楼 rogerhunt 2009-07-21  

相关推荐

    wsdl4j 解析wsdl 文件

    WSDL4J是一个Java库,专门用于解析和操作Web服务描述语言(WSDL)文件。WSDL是一种XML格式,用于定义网络服务的接口,包括其输入、输出、操作和服务...通过深入学习WSDL4J,开发者可以更有效地实现服务的交互和集成。

    WSDL学习文档(学习web服务必用)

    Web Services Description Language (WSDL) 是一种基于XML的应用,它被用来详细描述Web服务的接口和功能,使得客户端能够找到并使用这些服务。WSDL文档是Web服务的核心组成部分,它定义了服务提供者和消费者之间的...

    wsdl4j api

    1. **WSDL模型**:WSDL4J提供了一个完整的WSDL模型,将WSDL文档解析为一系列Java对象,方便开发者进行操作。这些对象包括服务、端点、绑定、消息、PortType、Operation等。 2. **解析和生成**:库允许用户从XML文件...

    wsdl4j-bin-1.6.3.zip

    1. **解析WSDL文档**:Wsdl4j能够读取并解析WSDL文件,将XML内容转换为Java对象模型,使得开发者可以方便地访问和操作WSDL中的各种元素,如服务、端点、消息、操作等。 2. **构建WSDL文档**:除了解析,Wsdl4j还...

    wsdl4j-1.6.3-API文档-中文版.zip

    赠送jar包:wsdl4j-1.6.3.jar; 赠送原API文档:wsdl4j-1.6.3-javadoc.jar; 赠送源代码:wsdl4j-1.6.3-sources.jar; 赠送Maven依赖信息文件:wsdl4j-1.6.3.pom; 包含翻译后的API文档:wsdl4j-1.6.3-javadoc-API...

    wsdl4j解析wsdl文件例子代码

    一个用wsdl4j.jar,ws-commons-java5-1.0.1.jar,XmlSchema-1.3.2.jar完全解析wsdl的例子, 本例子原本是xcalia studio中的一个模块,拿来和初次接触的人参考,因为我走了很多弯路,希望别人能少走。

    wsdl.rar_WSDL

    WSDL文档会指定服务使用SOAP的消息格式,定义消息的结构以及服务的调用方式。 **3. WSDL的使用场景** - **服务发布**:服务提供者创建WSDL文档来声明其服务的接口和行为,然后发布到一个可发现的位置,以便其他...

    根据wsdl生成webservice服务端(3种方式)

    本文将详细介绍三种基于WSDL生成WebService服务端的方法:使用`wsdl2java`命令、通过SOAPUI工具及借助MyEclipse的Web Service项目功能。 #### 方法一:使用`wsdl2java`命令生成 `wsdl2java`是Apache CXF提供的一个...

    WebService之WSDL自学笔记

    ### WebService之WSDL自学笔记 #### 1、WSDL概述 WSDL(Web Services Description Language,网络服务描述语言)是一种基于XML的标准语言,用于描述Web服务及其如何被访问。WSDL提供了描述服务的方式,包括服务的...

    wsdl4j-1.5.2

    WSDL(Web Services Description Language)是一种XML格式,用于定义Web服务的接口,描述服务提供的操作、输入、输出消息以及它们之间的交互方式。WSDL4J是一个Java库,它允许开发人员在Java应用程序中解析、创建和...

    wsdl需要的jar包

    1. **WSDL结构**:WSDL文件由多个主要元素组成,如`&lt;service&gt;`定义服务接口,`&lt;portType&gt;`定义操作集合,`&lt;binding&gt;`定义传输协议和消息格式,`&lt;port&gt;`定义服务的实例,以及`&lt;message&gt;`定义交换的数据结构。...

    wsdl调用测试工具

    在IT行业中,WSDL(Web Services Description Language)是一种XML格式的规范,用于描述Web服务及其接口。它定义了服务提供商和消费者之间的交互方式,包括消息格式、操作、地址和协议等。当我们面对“WSDL调用测试...

    WSDL网络资源整理版

    WSDL描述了如何通过SOAP调用Web服务,包括SOAP消息的结构和发送方式。 **四、WSDL的使用场景** 1. **服务发现**:客户端可以通过查找WSDL文件来发现可用的Web服务。 2. **服务消费**:服务消费者可以根据WSDL来生成...

    WSDL.rar_C# 解析wsdl文件_WSDL_解析WSDL

    在IT行业中,Web服务是应用程序之间交互的一种标准方式,而WSDL(Web Services Description Language)则是用来定义这些服务接口的XML格式规范。本项目“WSDL.rar”提供了一个C#编写的WSDL解析器,旨在帮助开发者更...

    WebService的实现——CXF学习笔记

    【WebService的实现——CXF学习笔记】 在Java世界中,WebService是一种通过标准协议(如SOAP)进行跨平台、跨语言通信的技术。CXF是Apache软件基金会的一个开源项目,它提供了构建和消费Web服务的工具和库。CXF支持...

    AxisLib1.4.rar(包括wsdl4j)

    WSDL是一种XML格式的规范,用于描述Web服务及其接口,包括服务提供的操作、消息格式、通信协议等。WSDL4J提供API,允许开发者解析、创建和修改WSDL文件,便于Web服务的开发、测试和集成。 在实际应用中, Axis与...

    SoapUI测试工具WSDL文件生成--个人总结

    WSDL(Web Services Description Language)是一种基于XML的语言,用于描述网络服务(如SOAP Web服务)的接口和消息格式。WSDL文件通常包含以下几部分: - **定义**:包括命名空间和导入其他WSDL文件的信息。 - **...

    JavaScript 调用wsdl示例

    1. **获取WSDL定义**:这通常涉及到一个后端代理或者使用支持WSDL解析的库。例如,`Zepo SOAP`库允许你提供WSDL URL,然后解析并构建相应的SOAP服务客户端。 2. **创建SOAP客户端**:一旦WSDL被解析,你可以创建一...

    简单WSDL实例

    WSDL,全称为Web Services Description Language,是用于描述Web服务的一种XML格式。它定义了服务的接口,包括服务提供的操作、消息格式、通信协议以及服务的位置。WSDL文件是Web服务客户端和服务提供者之间进行交互...

    wsdl例子wsdl例子wsdl例子

    **标题与描述解析:** 标题中的“wsdl例子”重复多次,显然在强调WSDL(Web Service ..."wsdl4j"作为处理WSDL的工具库,为Java开发者提供了强大的支持。理解和掌握WSDL及其相关工具对于进行Web服务开发至关重要。

Global site tag (gtag.js) - Google Analytics