Я новичок в мире WSDL. Я определил образец WSDL. Но когда я импортирую WSDL в Soap UI, он не показывает полезную нагрузку сообщения XML. Мне нужно знать, что я делаю неправильно. Когда я проверяю WSDL, он не может разрешить «pushtype», на который я ссылаюсь в сообщении.
Странно, но пользовательский интерфейс SOAP не выдает никакой ошибки, когда я импортирую в него WSDL.
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>
В вашем WSDL было несколько ошибок проверки, поэтому я внес следующие изменения:
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
push
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 , хотя и старая, полна золота.