无法将消息有效负载从WSDL导入到SoapUI

问题描述 投票:0回答:1

我是WSDL世界的新手。我已经定义了一个示例WSDL,但是当我将WSDL导入Soap UI时,它不会显示xml消息有效负载。我需要知道我在做什么错。当我验证WSDL时,它无法解析消息中所指的“推送类型”。

奇怪的是,当我在其中导入WSDL时,SOAP UI不会引发任何错误。

WSDL:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://ws.apache.org/axis2" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"  xmlns:tkl="http://example.org/" xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns:tk="http://example.org/" targetNamespace="http://ws.apache.org/axis2">
   <wsdl:types>
        <xsd:schema xmlns:tkl="http://example.org/" targetNamespace="http://example.org/" elementFormDefault="unqualified">
             <xsd:element name="push" type="tk:pushType"/>
             <xsd:complexType name="pushType">
              <xsd:sequence>
               <xsd:element name="exchnage" type="tkl:exchangeType" minOccurs="1" maxOccurs="1"/>
              </xsd:sequence>
             </xsd:complexType>

            <xsd:complexType name="exchangeType">
              <xsd:sequence>
                <xsd:element minOccurs="1" maxOccurs="1" name="equipment" type="xsd:string"/>
                <xsd:element minOccurs="1" maxOccurs="1" name="kind" type="xsd:string" />
                <xsd:element minOccurs="1" maxOccurs="1" name="source" type="xsd:string" />
                <xsd:element minOccurs="1" maxOccurs="1" name="status" type="xsd:string" />
                <xsd:element minOccurs="2" maxOccurs="2" name="files" type="tkl:fileType" />
              </xsd:sequence>
             </xsd:complexType>
             <xsd:complexType name="fileType">
              <xsd:sequence>
               <xsd:element minOccurs="1" maxOccurs="1" name="name" type="xsd:string" />
               <xsd:element minOccurs="1" maxOccurs="1" name="size" type="xsd:string" />
               <xsd:element minOccurs="1" maxOccurs="1" name="type" type="xsd:string" />
               <xsd:element minOccurs="1" maxOccurs="1" name="content" type="xsd:string" />
              </xsd:sequence>
             </xsd:complexType>
        </xsd:schema>
   </wsdl:types>
   <wsdl:message name="in">
        <wsdl:part name="push" type="tkl:pushType"/>
   </wsdl:message>
   <wsdl:message name="out" />
   <wsdl:portType name="qm.axisDiagnosis.results_mockPortType">
      <wsdl:operation name="mediate">
         <wsdl:input message="tns:in" wsaw:Action="urn:mediate" />
         <wsdl:output message="tns:out" wsaw:Action="urn:mediateResponse" />
      </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="qm.axisDiagnosis.results_mockSoap11Binding" type="tns:qm.axisDiagnosis.results_mockPortType">
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
      <wsdl:operation name="mediate">
         <soap:operation soapAction="urn:mediate" style="document" />
         <wsdl:input>
            <soap:body use="literal" />
         </wsdl:input>
         <wsdl:output>
            <soap:body use="literal" />
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:binding name="qm.axisDiagnosis.results_mockSoap12Binding" type="tns:qm.axisDiagnosis.results_mockPortType">
      <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
      <wsdl:operation name="mediate">
         <soap12:operation soapAction="urn:mediate" style="document" />
         <wsdl:input>
            <soap12:body use="literal" />
         </wsdl:input>
         <wsdl:output>
            <soap12:body use="literal" />
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:binding name="qm.axisDiagnosis.results_mockHttpBinding" type="tns:qm.axisDiagnosis.results_mockPortType">
      <http:binding verb="POST" />
      <wsdl:operation name="mediate">
         <http:operation location="mediate" />
         <wsdl:input>
            <mime:content type="text/xml" part="parameters" />
         </wsdl:input>
         <wsdl:output>
            <mime:content type="text/xml" part="parameters" />
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="qm.axisDiagnosis.results_mock">
      <wsdl:port name="qm.axisDiagnosis.results_mockHttpSoap11Endpoint" binding="tns:qm.axisDiagnosis.results_mockSoap11Binding">
         <soap:address location="http://example.com.com:8280/services/qm.axisDiagnosis.results_mock.qm.axisDiagnosis.results_mockHttpSoap11Endpoint" />
      </wsdl:port>
      <wsdl:port name="qm.axisDiagnosis.results_mockHttpsSoap11Endpoint" binding="tns:qm.axisDiagnosis.results_mockSoap11Binding">
         <soap:address location="https://example.com.com:8243/services/qm.axisDiagnosis.results_mock.qm.axisDiagnosis.results_mockHttpsSoap11Endpoint" />
      </wsdl:port>
      <wsdl:port name="qm.axisDiagnosis.results_mockHttpsSoap12Endpoint" binding="tns:qm.axisDiagnosis.results_mockSoap12Binding">
         <soap12:address location="https://example.com.com:8243/services/qm.axisDiagnosis.results_mock.qm.axisDiagnosis.results_mockHttpsSoap12Endpoint" />
      </wsdl:port>
      <wsdl:port name="qm.axisDiagnosis.results_mockHttpSoap12Endpoint" binding="tns:qm.axisDiagnosis.results_mockSoap12Binding">
         <soap12:address location="http://example.com.com:8280/services/qm.axisDiagnosis.results_mock.qm.axisDiagnosis.results_mockHttpSoap12Endpoint" />
      </wsdl:port>
      <wsdl:port name="qm.axisDiagnosis.results_mockHttpsEndpoint" binding="tns:qm.axisDiagnosis.results_mockHttpBinding">
         <http:address location="https://example.com.com:8243/services/qm.axisDiagnosis.results_mock.qm.axisDiagnosis.results_mockHttpsEndpoint" />
      </wsdl:port>
      <wsdl:port name="qm.axisDiagnosis.results_mockHttpEndpoint" binding="tns:qm.axisDiagnosis.results_mockHttpBinding">
         <http:address location="http://example.com.com:8280/services/qm.axisDiagnosis.results_mock.qm.axisDiagnosis.results_mockHttpEndpoint" />
      </wsdl:port>
   </wsdl:service>
</wsdl:definitions>

当前输出:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <push/>
   </soapenv:Body>
</soapenv:Envelope>

预期输出:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:trum="http://example.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <trum:push>
         <!--Mandatory:-->
         <exchange>
          <equipment>equipment</equipment>
    <kind>kind</kind>
    <source>source</source>
    <status>status</status>
    <files>
      <name>name</name>
      <size>size</size>
      <type>type</type>
      <content>content</content>
    </files>
    <files>
      <name>name</name>
      <size>size</size>
      <type>type</type>
      <content>content</content>
    </files>
         </exchange>
      </trum:push>
   </soapenv:Body>
</soapenv:Envelope>
xml soap wsdl soapui
1个回答
0
投票

您的WSDL有一些验证错误,所以我进行了以下更改:

  • 将名称空间xmlns:xsd="http://www.w3.org/2001/XMLSchema"带入XML模式定义部分。
  • 由于您正在使用正确的数据类型在push中定义push,因此从WSDL的XML模式部分中删除了wsdl:message元素。

您的WSDL随后将如下所示并通过验证:

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://ws.apache.org/axis2" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"  xmlns:tkl="http://example.org/" xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns:tk="http://example.org/" targetNamespace="http://ws.apache.org/axis2">
    <wsdl:types>
        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.org/" elementFormDefault="unqualified">
            <xsd:complexType name="pushType">
                <xsd:sequence>
                    <xsd:element name="exchnage" type="tkl:exchangeType" minOccurs="1" maxOccurs="1"/>
                </xsd:sequence>
            </xsd:complexType>

            <xsd:complexType name="exchangeType">
                <xsd:sequence>
                    <xsd:element minOccurs="1" maxOccurs="1" name="equipment" type="xsd:string"/>
                    <xsd:element minOccurs="1" maxOccurs="1" name="kind" type="xsd:string" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="source" type="xsd:string" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="status" type="xsd:string" />
                    <xsd:element minOccurs="2" maxOccurs="2" name="files" type="tkl:fileType" />
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="fileType">
                <xsd:sequence>
                    <xsd:element minOccurs="1" maxOccurs="1" name="name" type="xsd:string" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="size" type="xsd:string" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="type" type="xsd:string" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="content" type="xsd:string" />
                </xsd:sequence>
            </xsd:complexType>
        </xsd:schema>
    </wsdl:types>
    <wsdl:message name="in">
        <wsdl:part name="push" type="tkl:pushType"/>
    </wsdl:message>
    <wsdl:message name="out" />
    <wsdl:portType name="qm.axisDiagnosis.results_mockPortType">
        <wsdl:operation name="mediate">
            <wsdl:input message="tns:in" wsaw:Action="urn:mediate" />
            <wsdl:output message="tns:out" wsaw:Action="urn:mediateResponse" />
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="qm.axisDiagnosis.results_mockSoap11Binding" type="tns:qm.axisDiagnosis.results_mockPortType">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
        <wsdl:operation name="mediate">
            <soap:operation soapAction="urn:mediate" style="document" />
            <wsdl:input>
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name="qm.axisDiagnosis.results_mockSoap12Binding" type="tns:qm.axisDiagnosis.results_mockPortType">
        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
        <wsdl:operation name="mediate">
            <soap12:operation soapAction="urn:mediate" style="document" />
            <wsdl:input>
                <soap12:body use="literal" />
            </wsdl:input>
            <wsdl:output>
                <soap12:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name="qm.axisDiagnosis.results_mockHttpBinding" type="tns:qm.axisDiagnosis.results_mockPortType">
        <http:binding verb="POST" />
        <wsdl:operation name="mediate">
            <http:operation location="mediate" />
            <wsdl:input>
                <mime:content type="text/xml" part="parameters" />
            </wsdl:input>
            <wsdl:output>
                <mime:content type="text/xml" part="parameters" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="qm.axisDiagnosis.results_mock">
        <wsdl:port name="qm.axisDiagnosis.results_mockHttpSoap11Endpoint" binding="tns:qm.axisDiagnosis.results_mockSoap11Binding">
            <soap:address location="http://example.com.com:8280/services/qm.axisDiagnosis.results_mock.qm.axisDiagnosis.results_mockHttpSoap11Endpoint" />
        </wsdl:port>
        <wsdl:port name="qm.axisDiagnosis.results_mockHttpsSoap11Endpoint" binding="tns:qm.axisDiagnosis.results_mockSoap11Binding">
            <soap:address location="https://example.com.com:8243/services/qm.axisDiagnosis.results_mock.qm.axisDiagnosis.results_mockHttpsSoap11Endpoint" />
        </wsdl:port>
        <wsdl:port name="qm.axisDiagnosis.results_mockHttpsSoap12Endpoint" binding="tns:qm.axisDiagnosis.results_mockSoap12Binding">
            <soap12:address location="https://example.com.com:8243/services/qm.axisDiagnosis.results_mock.qm.axisDiagnosis.results_mockHttpsSoap12Endpoint" />
        </wsdl:port>
        <wsdl:port name="qm.axisDiagnosis.results_mockHttpSoap12Endpoint" binding="tns:qm.axisDiagnosis.results_mockSoap12Binding">
            <soap12:address location="http://example.com.com:8280/services/qm.axisDiagnosis.results_mock.qm.axisDiagnosis.results_mockHttpSoap12Endpoint" />
        </wsdl:port>
        <wsdl:port name="qm.axisDiagnosis.results_mockHttpsEndpoint" binding="tns:qm.axisDiagnosis.results_mockHttpBinding">
            <http:address location="https://example.com.com:8243/services/qm.axisDiagnosis.results_mock.qm.axisDiagnosis.results_mockHttpsEndpoint" />
        </wsdl:port>
        <wsdl:port name="qm.axisDiagnosis.results_mockHttpEndpoint" binding="tns:qm.axisDiagnosis.results_mockHttpBinding">
            <http:address location="http://example.com.com:8280/services/qm.axisDiagnosis.results_mock.qm.axisDiagnosis.results_mockHttpEndpoint" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

如果将此WSDL导入soapUI,则SOAP有效负载应类似于:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <push>
         <exchnage>
            <equipment>?</equipment>
            <kind>?</kind>
            <source>?</source>
            <status>?</status>
            <files>
               <name>?</name>
               <size>?</size>
               <type>?</type>
               <content>?</content>
            </files>
            <files>
               <name>?</name>
               <size>?</size>
               <type>?</type>
               <content>?</content>
            </files>
         </exchnage>
      </push>
   </soapenv:Body>
</soapenv:Envelope>

注意:如果您将更多地使用WSDL,最终您将需要深入了解名称空间。文章XML Namespaces FAQ尽管年代久远,但却充满了金子。

© www.soinside.com 2019 - 2024. All rights reserved.