在 WSDL 中包含 XSD [英] Include an XSD in WSDL

查看:28
本文介绍了在 WSDL 中包含 XSD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个 wsdl 文件来在未来 (SoapUI) 中部署一个模拟服务,但是我在包含我的 xsd 文件时遇到了问题.

I am writing a wsdl file to deploy a mockservice in futur (SoapUI) but i have a problem to include my xsd file.

XSD 文件

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" elementFormDefault="qualified" attributeFormDefault="unqualified" vc:minVersion="1.1">
    <!--Déclaration des types complexes -->
    <xs:complexType name="TSujet">
        <xs:sequence>
            <xs:element name="identifiant" type="xs:string"/>
            <xs:element name="libelleCourt" type="xs:string"/>
            <xs:element name="libelleLong" type="xs:string"/>
            <xs:element name="incidents">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="incident" type="TRefIncident" minOccurs="0" maxOccurs="unbounded"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="TRefIncident">
        <xs:sequence>
            <xs:element name="identifiant" type="xs:string"/>
            <xs:element name="libelle" type="xs:string"/>
            <xs:element name="erreursConnues">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="erreurConnue" type="TErreurConnue" minOccurs="0" maxOccurs="unbounded"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="TErreurConnue">
        <xs:sequence>
            <xs:element name="identifiant" type="xs:string"/>
            <xs:element name="texte" type="xs:string"/>
            <xs:element name="documents">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="document" type="TDocument" minOccurs="0" maxOccurs="unbounded"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="TDocument">
        <xs:sequence>
            <xs:element name="identifiant" type="xs:string"/>
            <xs:element name="type" type="xs:string"/>
            <xs:element name="contenu" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="TUtilisateur">
        <xs:sequence>
            <xs:element name="login" type="xs:string"/>
            <xs:element name="nom" type="xs:string"/>
            <xs:element name="prenom" type="xs:string"/>
            <xs:element name="codePoste" type="xs:string"/>
            <xs:element name="telephone" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
    <!-- Déclaration des éléments -->
    <xs:complexType name="TTheme">
        <xs:sequence>
            <xs:element name="identifiant" type="xs:string"/>
            <xs:element name="libelleCourt" type="xs:string"/>
            <xs:element name="libelleLong" type="xs:string"/>
            <xs:element name="top" type="xs:string" minOccurs="0" maxOccurs="5"/>
            <xs:element name="sujets">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="sujet" type="TSujet" minOccurs="0" maxOccurs="unbounded"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="TTicket">
        <xs:sequence>
            <xs:element name="identifiant" type="xs:string"/>
            <xs:element name="libelle" type="xs:string"/>
            <xs:element name="date" type="xs:string"/>
            <xs:element name="document" type="xs:string"/>
            <xs:element name="objet" type="xs:string"/>
            <xs:element name="description" type="xs:string"/>
            <xs:element name="destinataire" type="xs:string"/>
            <xs:element name="statut" type="xs:string"/>
            <xs:element name="commentaire" type="xs:string"/>
            <xs:element name="refIncident" type="TRefIncident"/>
            <xs:element name="utilisateur" type="TUtilisateur"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="TNews">
        <xs:sequence>
            <xs:element name="identifiant" type="xs:string"/>
            <xs:element name="libelle" type="xs:string"/>
            <xs:element name="description" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="TIncidentDeMasse">
        <xs:sequence>
            <xs:element name="identifiant" type="xs:string"/>
            <xs:element name="libelle" type="xs:string"/>
            <xs:element name="description" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
</xs:schema>

WSDL 文件

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

  <wsdl:types>
    <xsd:schema targetNamespace="http://www.example.org/passerelle/">
      <include schemaLocation="schema.xsd"/>
    </xsd:schema>
  </wsdl:types>

  <wsdl:message name="getAllCatalogueResponse">
    <wsdl:part name="catalogue" type="tns:TTheme"/>
  </wsdl:message>
  <wsdl:message name="createTicketRequest">
    <wsdl:part name="data" type="tns:TTicket"></wsdl:part>
  </wsdl:message>
  <wsdl:message name="createTicketResponse">
    <wsdl:part name="return" type="xsd:string"></wsdl:part>
  </wsdl:message>
  <wsdl:message name="getTicketsRequest">
    <wsdl:part name="idUser" type="xsd:string"></wsdl:part>
  </wsdl:message>
  <wsdl:message name="getTicketsResponse">
    <wsdl:part name="tickets" type="tns:TTicket"></wsdl:part>
  </wsdl:message>
  <wsdl:message name="getMessagesResponse">
    <wsdl:part name="incidents" type="tns:TIncidentDeMasse"></wsdl:part>
    <wsdl:part name="news" type="tns:TNews"></wsdl:part>
  </wsdl:message>

  <wsdl:portType name="passerelle">
    <wsdl:operation name="getAllCatalogue">
      <wsdl:output message="tns:getAllCatalogueResponse"/>
    </wsdl:operation>
    <wsdl:operation name="createTicket">
        <wsdl:input message="tns:createTicketRequest"></wsdl:input>
        <wsdl:output message="tns:createTicketResponse"></wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getTickets">
        <wsdl:input message="tns:getTicketsRequest"></wsdl:input>
        <wsdl:output message="tns:getTicketsResponse"></wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getMessages">
        <wsdl:output message="tns:getMessagesResponse"></wsdl:output>
    </wsdl:operation>
  </wsdl:portType>

  <wsdl:binding name="passerelleSOAP" type="tns:passerelle">
    <soap:binding style="document"
        transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="getAllCatalogue">
        <soap:operation
            soapAction="http://www.example.org/passerelle/getAllCatalogue" />
        <wsdl:input>
            <soap:body use="literal" />
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal" />
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="createTicket">
        <soap:operation
            soapAction="http://www.example.org/passerelle/createTicket" />
        <wsdl:input>
            <soap:body use="literal" />
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal" />
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getTickets">
        <soap:operation
            soapAction="http://www.example.org/passerelle/getTickets" />
        <wsdl:input>
            <soap:body use="literal" />
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal" />
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getMessages">
        <soap:operation
            soapAction="http://www.example.org/passerelle/getMessages" />
        <wsdl:output>
            <soap:body use="literal" />
        </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>

  <wsdl:service name="passerelle">
    <wsdl:port binding="tns:passerelleSOAP" name="passerelleSOAP">
      <soap:address location="http://www.example.org/"/>
    </wsdl:port>
  </wsdl:service>

</wsdl:definitions>

你有什么建议吗?如何知道文件是否包含在内?我使用 Eclipse 来编辑它们.

Do you have any suggestions? how to know if the file is included? I use Eclipse to edit them.

推荐答案

在 wsdl 中使用 标签

Using the <xs:import> tag in your wsdl

<wsdl:types>
    <xs:schema>
        <xs:import namespace="http://www.example.org/passerelle" schemaLocation="schema.xsd"/>
    </xsd:schema>
</wsdl:types>

这篇关于在 WSDL 中包含 XSD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆