WSDL 的配置

WSDL 标准:http://www.w3.org/TR/wsdl

请参看上述网站的内容。

我写的这篇帖子只是作为参考,加深理解。

 

wsdl的结构划分

1、WSDL 头定义

例如:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.sccs.sunyard.com/wxtcService/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="wxtcService" targetNamespace="http://www.sccs.sunyard.com/wxtcService/">

其中 xmlns:tns、 targetNamespace是需要自己定义的,当然你也可以保留默认http://example.com

2、wsdl:types

wsdl:types 允许你定义一些<xsd:element/>及<xsd:complexType>

定义这些时,有一些xml schemal 的常识有助于你的理解。

示例:

 <wsdl:types>

<xsd:schema targetNamespace="http://www.sccs.sunyard.com/wxtcService/">

 <xsd:complexType name="RequestHeader">
        <xsd:sequence>
         <xsd:element name="businessAcceptId" type="xsd:string"></xsd:element>
         <xsd:element name="TrnCode" type="xsd:string"></xsd:element>
            </xsd:sequence>
      </xsd:complexType>

 

 <xsd:element name="TestService">
        <xsd:complexType>
        <xsd:sequence>
         <xsd:element name="in" type="xsd:string"></xsd:element>
        </xsd:sequence>
         </xsd:complexType>
       </xsd:element>
 <xsd:element name="TestServiceRequest">
           <xsd:complexType>
             <xsd:sequence>
                 <xsd:element name="RequestHeader" type="tns:RequestHeader"></xsd:element>
               </xsd:sequence>
         </xsd:complexType>
       </xsd:element>

  <xsd:element name="TestServiceResponse">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element name="ResponseHeader" type="tns:ResponseHeader"></xsd:element>
                    <xsd:element name="Content">
                        <xsd:complexType>
                            <xsd:sequence>
                                 <xsd:element name="RequestHeader" type="tns:RequestHeader"></xsd:element>
                               </xsd:sequence>
                        </xsd:complexType>
                    </xsd:element>
                </xsd:sequence>
            </xsd:complexType>
</xsd:element> 

</wsdl:types>

 

3、wsdl:message

用于定义webservice的输入和输出。

示例:

  <wsdl:message name="TestServiceRequest">
   <wsdl:part name="parameters" element="tns:TestServiceRequest"></wsdl:part>
  </wsdl:message>
  <wsdl:message name="TestServiceResponse">
   <wsdl:part name="parameters" element="tns:TestServiceResponse"></wsdl:part>
  </wsdl:message>

4、wsdl:portType

定义webservice的主体。webservice将在这里组成。

<wsdl:portType>

    <wsdl:operation name="TestService">
          <wsdl:documentation>测试示例</wsdl:documentation>
           <wsdl:input message="tns:TestServiceRequest"></wsdl:input>
         <wsdl:output message="tns:TestServiceResponse"></wsdl:output>
          </wsdl:operation>

</wsdl:portType>

 

在这里引用前面message中定义的内容,组成webservice的访问主体,包括输入、输出等。

5、wsdl:binding

可以将binding看成访问webservice的入口。

 <wsdl:binding name="WXTCServiceSOAPBinding" type="tns:IWXTCService">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

    <wsdl:operation name="TestService">
      <soap:operation soapAction="http://www.sccs.sunyard.com/wxtcService/TestService"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>

  </wsdl:binding>

若这里没有定义TestService ,则TestService 将不可访问。

 

6、  wsdl:service

webservice的总入口,实际上,在wsdl的编辑工具中,该部件的图标就是一个接口图标。

这与其在整体wsdl中的位置很恰当

<wsdl:service name="WXTCService">
    <wsdl:port binding="tns:WXTCServiceSOAPBinding" name="IWXTCServicePort">
      <soap:address location="http://localhost:8000/SCCS/services/WXTCService"/>
    </wsdl:port>
  </wsdl:service>

 

 

总结:

wsdl 的调用流程?

wsdl:service==>wsdl:binding==>wsdl:portType==>message==>wsdl:types

 

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值