WebService中WSDL文件详解

WSDL(Web Service Description Language)Web服务描述语言

################################################################################

适用于描述WebService的文档格式


下面例子是为了输入一个字符串name,返回一个SayHello的操作。


<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions
    
targetNamespace="http://com.liuxiang.xfireDemo/HelloService"-------------------DEFINITIONS:WSDL文档根元素,提供命名空间
    xmlns:tns
="http://com.liuxiang.xfireDemo/HelloService"
    xmlns:wsdlsoap
="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:soap12
="http://www.w3.org/2003/05/soap-envelope"
    xmlns:xsd
="http://www.w3.org/2001/XMLSchema"
    xmlns:soapenc11
="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:soapenc12
="http://www.w3.org/2003/05/soap-encoding"
    xmlns:soap11
="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:wsdl
="http://schemas.xmlsoap.org/wsdl/">
 
   <wsdl:types>-------------------------------------------------------------------------------------TYPE:数据类型定义的容器,TYPE定义了两个元
        
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 素,一个是sayHello,一个是sayHelloResp
            attributeFormDefault
="qualified" elementFormDefault="qualified" onse。
            targetNamespace
="http://com.liuxiang.xfireDemo/HelloService">
            
<xsd:element name="sayHello">----------------------------------------sayHello
                
<xsd:complexType>
                    
<xsd:sequence>
                        
<xsd:element maxOccurs="1" minOccurs="1"
                            name
="name" nillable="true" type="xsd:string" />
                    
</xsd:sequence>
                
</xsd:complexType>
            
</xsd:element>
            
<xsd:element name="sayHelloResponse">---------------------------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>
    
<wsdl:message name="sayHelloResponse">----------------------------------------------MESSAGE:通信消息的数据结构的抽象化定义,描
        
<wsdl:part name="parameters" element="tns:sayHelloResponse" />                                         述了Web服务使用消息的有效负载,
    
</wsdl:message>     还可描述输出或接受消息的有效负载
    
<wsdl:message name="sayHelloRequest">     ,其中ELEMENT对应TYPE中的NAME。定义元
        
<wsdl:part name="parameters" element="tns:sayHello" />      素的方式取决于使用RPC样式或文档样式,此处
    
</wsdl:message>     为文档样式

    <wsdl:portType name="HelloServicePortType">------------------------------------------PORTTYPE:对于某个访问入口点类型所支持的操
        
<wsdl:operation name="sayHello">                                                                                              的抽象集合,一个portType可定义多
            
<wsdl:input name="sayHelloRequest"      个operation,一个operation可看做一
                message
="tns:sayHelloRequest" />      个方法,请求消息是MESSAGE定义的
            
<wsdl:output name="sayHelloResponse"      sayHelloRequest,相应消息是
                message
="tns:sayHelloResponse" />      sayHelloResponse,同时包含input
        
</wsdl:operation>      /output表明这是一个请求/响应模式,
    
</wsdl:portType>      input表示传递到Web服务的有效负

      载,output表示传递到客户的有效负       载.此处TNS为DEFINITIONS中所声       明。
   
 <wsdl:binding name="HelloServiceHttpBinding"--------------------------------------------BINDING:特定端口类型的具体协议和数据格式规
        type
="tns:HelloServicePortType">     范的绑定,binding将一个抽象porType映
        
<wsdlsoap:binding style="document" 射到一组具体协议(SOAP/HTTP),消息传
            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>
    
<wsdl:service name="HelloService">----------------------------------------------------------SERVICE:相关服务访问点的集合,一个service元
        
<wsdl:port name="HelloServiceHttpPort"     素包含多个不同的port,每个port表示
            binding
="tns:HelloServiceHttpBinding">     不同的Web服务,此例子中提供给访
            
<wsdlsoap:address     问你的地址为:http://localhost:8080/xf.
                
location="http://localhost:8080/xfire/services/HelloService" />      .....
        
</wsdl:port>
    
</wsdl:service>
</wsdl:definitions>


IMPORT:可以让当前WSDL文档中引用其他WSDL文档中指定命名空间中的元素,通常用于WSDL模块化。

<wsdl:import namespace="http://xxx.xxx.xxx/xxx/xxx" location="http://xxx.xxx.xxx/xxx/xxx.wsdl"/>

namespace属性:必须与所导入文件的targetNameSpace名称相同.

        location属性:指向wsdl文件的路径,不能为空.

附WSDL文档结构图-------


以上这些就是基本的一些要点,,,如果有误,请各位大爷批评指正,,,

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

扶朕去网吧

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值