如何为此xml doc创建xsd shema? 我尝试了很多解决方案,但没有任何解决方案。
<?xml version="1.0" encoding="utf-8"?>
<e:Envelope xmlns:e="http://www.w3.org/2003/05/soap-envelope">
<e:Header>
<RequestInfo Type="SetConfig" Id="AB1y0WzRv42Nz4G8V+UW">
<ReturnAddresses>
<Address>
mars@contact
</Address>
</ReturnAddresses>
</RequestInfo>
</e:Header>
<e:Body>
<RequestData>
MIIBhzCCAYOgAwIBADCCAXowfDB6M
</RequestData>
</e:Body>
</e:Envelope>
答案 0 :(得分:0)
如果你正在寻找一个wsdl(自从我写了一个wsdl已经很多年了,但我相信这对你来说是一个很好的起点)
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:sample/service"
xmlns:tns="urn:sample/service" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:types="urn:sample/types">
<wsdl:types>
<xs:schema targetNamespace="urn:sample/types" elementFormDefault="qualified"
xmlns:tns="urn:sample/types">
<xs:simpleType name="TSimpleEmail">
<xs:restriction base="xs:token">
<xs:pattern value="[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="TRequestInfo">
<xs:sequence>
<xs:element name="ReturnAddresses">
<xs:complexType>
<xs:sequence>
<xs:element name="Address" type="tns:TSimpleEmail"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Type" type="xs:token"/>
<xs:attribute name="Id" type="xs:token"/>
</xs:complexType>
<xs:element name="RequestInfo" type="tns:TRequestInfo"/>
<xs:element name="RequestData" type="xs:token"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="SampleRequestMsg">
<wsdl:part name="p0" element="types:RequestData"/>
</wsdl:message>
<wsdl:message name="SampleRequestHeader">
<wsdl:part name="p0" element="types:RequestInfo"/>
</wsdl:message>
<wsdl:portType name="SamplePortType">
<wsdl:operation name="some-sample-operation">
<wsdl:input message="tns:SampleRequestMsg"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SampleSOAPBinding" type="tns:SamplePortType"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="some-sample-operation">
<soap:operation soapAction="sample"/>
<wsdl:input>
<soap:header message="tns:SampleRequestHeader" part="p0" use="literal"/>
<soap:body parts="p0" use="literal"/>
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SampleService">
<wsdl:port name="SamplePort" binding="tns:SampleSOAPBinding">
<soap:address xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" location="none"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
注意标头和正文如何在SOAP绑定中映射。
如果您只是在寻找XSD,请仅提取该部分
<xs:schema targetNamespace="urn:sample/types" elementFormDefault="qualified"
xmlns:tns="urn:sample/types">
<xs:simpleType name="TSimpleEmail">
<xs:restriction base="xs:token">
<xs:pattern value="[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="TRequestInfo">
<xs:sequence>
<xs:element name="ReturnAddresses">
<xs:complexType>
<xs:sequence>
<xs:element name="Address" type="tns:TSimpleEmail"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Type" type="xs:token"/>
<xs:attribute name="Id" type="xs:token"/>
</xs:complexType>
<xs:element name="RequestInfo" type="tns:TRequestInfo"/>
<xs:element name="RequestData" type="xs:token"/>
</xs:schema>
使用soapUI生成的示例请求
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="urn:sample/types">
<soapenv:Header>
<typ:RequestInfo Type="?" Id="?">
<typ:ReturnAddresses>
<typ:Address>?</typ:Address>
</typ:ReturnAddresses>
</typ:RequestInfo>
</soapenv:Header>
<soapenv:Body>
<typ:RequestData>?</typ:RequestData>
</soapenv:Body>
</soapenv:Envelope>