webservice wsdl文件标签讲解

<?xml version="1.0" encoding="utf8"?>
<wsdl:definitions targetNamespace="http://www.57market.com.cn/HelloService" 
	xmlns:soapenc12="http://www.w3.org/2003/05/soapencoding" 
	xmlns:tns="http://www.57market.com.cn/HelloService" 
	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
	xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
	xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" 
	xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" 
	xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" 
	xmlns:soap12="http://www.w3.org/2003/05/soapenvelope">
	<!--
	 * type元素,定义了交换信息的数据格式。
	 * 为了实现最大的互操作性(interoperability)和平台中立性(neutrality),WSDL选用XML Schema DataTypes
	 * 简称XSD作为标准类型系统,并将它作为固有类型系统。
	 * 下面是数据定义部分,该部分定义了两个元素,一个是sayHello,一个是sayHelloResponse:
	 * sayHello:定义了一个复杂类型,仅仅包含一个简单的字符串,将来用来描述操作的参入传入部分;
	 * sayHelloResponse:定义了一个复杂类型,仅仅包含一个简单的字符串,将来用来描述操作的返回值;
	-->
    <wsdl:types>
        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" 
					elementFormDefault="qualified" targetNamespace="http://www.57market.com.cn/HelloService">
            <xsd:element name="sayHello">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string" />
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="sayHelloResponse">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string" />
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:schema>
    </wsdl:types>
	<!--
	* message元素指定XML数据类型组成消息的各个部分。message元素用于定义操作的输入和输出参数。
	* 该部分是信息格式的抽象定义:定义了两个消息sayHelloResponse和sayHelloRequest:
	* sayHelloRequest:sayHello操作的请求消息格式,由一个消息片断组成,名字为parameters,
	* 元素是我们前面定义的types中的元素;
	* sayHelloResponse:sayHello操作的响应消息格式,由一个消息片断组成,名字为parameters,
	* 元素是我们前面定义 *的types中的元素;
	* 如果采用RPC样式的消息传递,只需要将文档中的element元素应以修改为type即可。
	* message:用来定义消息的结构
	* part:指定引用types中定义的标签部分
	-->
    <wsdl:message name="sayHelloRequest">
        <wsdl:part name="parameters" element="tns:sayHello" />
    </wsdl:message>
    <wsdl:message name="sayHelloResponse">
        <wsdl:part name="parameters" element="tns:sayHelloResponse" />
    </wsdl:message>
	<!--
	* portType元素中定义了Web服务的操作。操作定义了输入和输出数据流中可以出现的XML消息。
	* 一些抽象操作的集合。每个操作关联一个输入消息和一个输出消息。
	* portType定义了服务的调用模式的类型,这里包含一个操作sayHello方法,同时包含input和output表明
	* 该操作是一个请求/响应模式,请求消息是前面定义的sayHelloRequest,
	* 响应消息是前面定义的sayHelloResponse。input表示传递到Web服务的有效负载,
	* output: 消息表示传递给客户的有效负载。
	* portType:用來定义服务端的SEI
	* operation:用來指定SEI中的處理請求的方法
	* input:指定客戶端应用传过来的数据,会引用上面的而定义的<message>
	* output:指定服务端返回给客戶端的数据,会引用上面的而定义的<message>
	-->
    <wsdl:portType name="HelloServicePortType">
        <wsdl:operation name="sayHello">
            <wsdl:input name="sayHelloRequest" message="tns:sayHelloRequest" />
            <wsdl:output name="sayHelloResponse" message="tns:sayHelloResponse" />
        </wsdl:operation>
    </wsdl:portType>
	<!--
	* binding元素描述特定服务接口的协议、数据格式、安全性和其它属性。
	* 针对操作和portType中使用的消息指定实际的协议和数据格式规范。
	* binding: 用于定义SEI的实现类
	* type属性:引用上面的<portType>
	* <soap:operation style="document" />绑定的数据是一个document(xml)
	* operation:用來定义实现的方法
	* <soap:operation style="document" />传输的是document(xml)
	* input:指定客戶端应用传过来的数据
	* <soap:body use="literal" />:文本数据
	* output:指定服务器端返回客戶端的数据
	* <soap:body use="literal"/>:文本数据
	-->
    <wsdl:binding name="HelloServiceHttpBinding" type="tns:HelloServicePortType">
        <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="sayHello">
            <wsdlsoap:operation soapAction="" />
            <wsdl:input name="sayHelloRequest">
                <wsdlsoap:body use="literal" />
            </wsdl:input>
            <wsdl:output name="sayHelloResponse">
                <wsdlsoap:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
	<!--
	* service元素。服务元素包含一组port元素。端口将端点与来自服务接口定义的binding元素关联起来。
	* port指定一个绑定的地址,这样定义一个通信的终端。
	* service:一個webservice的容器
	* name:属性:它用以指定一個服务器端处理请求的入口(就是SEI的实现)
	* binding属性:引用上面定义的<binding>
	* address:当前webservice的请求地址
	-->
    <wsdl:service name="HelloService">
        <wsdl:port name="HelloServiceHttpPort" binding="tns:HelloServiceHttpBinding">
            <soap:address location="http://localhost:8080/xfire/services/HelloService" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值