SOAP数据的正确格式是什么?

时间:2019-07-12 01:52:01

标签: soap format

我有一个文件,我在这里共享了http://codepad.org/V6FR2Wbs

似乎此文件包含SOAP数据。但是我不确定这是否包含SOAP数据。

所以我想知道,SOAP数据是否有任何特定格式。

我在What is the correct format of a SOAP response遇到了类似的问题,但是我在那看不到任何与格式有关的信息。

1 个答案:

答案 0 :(得分:1)

如果validaterequest response有效,有一种非常简单的方法来SOAPMessage

作为SOAP Message的一部分,它包含namespace,也指向SOAP XSDXML schema definition,并且该消息按照XSD的规定有效。

在您的示例中,SOAP消息是-

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cwmp="urn:dslforum-org:cwmp-1-0"> <SOAP-ENV:Header> <cwmp:ID SOAP-ENV:mustUnderstand="1">279384</cwmp:ID> </SOAP-ENV:Header> <SOAP-ENV:Body> <cwmp:Inform> <DeviceId> <Manufacturer>Huawei Technologies Co., Ltd</Manufacturer> <OUI>00259E</OUI> <ProductClass>EG8040H5</ProductClass> <SerialNumber>48575443FF5E5D9D</SerialNumber> </DeviceId> <Event SOAP-ENC:arrayType="cwmp:EventStruct[1]"> <EventStruct> <EventCode>2 PERIODIC</EventCode> <CommandKey/> </EventStruct> </Event> <MaxEnvelopes>1</MaxEnvelopes> <CurrentTime>2019-06-19T15:30:33+00:00</CurrentTime> <RetryCount>0</RetryCount> <ParameterList SOAP-ENC:arrayType="cwmp:ParameterValueStruct[8]"> <ParameterValueStruct> <Name>InternetGatewayDevice.ManagementServer.ParameterKey</Name> <Value xsi:type="xsd:string"/> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.ManagementServer.ConnectionRequestURL</Name> <Value xsi:type="xsd:string">http://10.240.12.35:7547/1d9564b694ef18090a9377cd6f3217eb</Value> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.DeviceSummary</Name> <Value xsi:type="xsd:string">InternetGatewayDevice:1.4[](Baseline:1, EthernetLAN:1, WiFiLAN:2, Time:1, IPPing:1, DeviceAssociation:1)</Value> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.DeviceInfo.SpecVersion</Name> <Value xsi:type="xsd:string">1.0</Value> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.DeviceInfo.HardwareVersion</Name> <Value xsi:type="xsd:string">172D.A</Value> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.DeviceInfo.SoftwareVersion</Name> <Value xsi:type="xsd:string">V5R019C00S115</Value> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.DeviceInfo.ProvisioningCode</Name> <Value xsi:type="xsd:string"/> </ParameterValueStruct> <ParameterValueStruct> <Name>InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress</Name> <Value xsi:type="xsd:string">10.240.12.35</Value> </ParameterValueStruct> </ParameterList> </cwmp:Inform> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

在您的示例中,SOAP模式位于http://schemas.xmlsoap.org/soap/envelope/

该模式的XSD是-

<?xml version='1.0' encoding='UTF-8' ?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"           xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/"
           targetNamespace="http://schemas.xmlsoap.org/soap/envelope/" >


  <!-- Envelope, header and body -->
  <xs:element name="Envelope" type="tns:Envelope" />
  <xs:complexType name="Envelope" >
    <xs:sequence>
      <xs:element ref="tns:Header" minOccurs="0" />
      <xs:element ref="tns:Body" minOccurs="1" />
      <xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
    </xs:sequence>
    <xs:anyAttribute namespace="##other" processContents="lax" />
  </xs:complexType>

  <xs:element name="Header" type="tns:Header" />
  <xs:complexType name="Header" >
    <xs:sequence>
      <xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
    </xs:sequence>
    <xs:anyAttribute namespace="##other" processContents="lax" />
  </xs:complexType>

  <xs:element name="Body" type="tns:Body" />
  <xs:complexType name="Body" >
    <xs:sequence>
      <xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
    </xs:sequence>
    <xs:anyAttribute namespace="##any" processContents="lax" >
      <xs:annotation>
        <xs:documentation>
          Prose in the spec does not specify that attributes are allowed on the Body element
        </xs:documentation>
      </xs:annotation>
    </xs:anyAttribute>
  </xs:complexType>


  <!-- Global Attributes.  The following attributes are intended to be usable via qualified attribute names on any complex type referencing them.  -->
  <xs:attribute name="mustUnderstand" > 
     <xs:simpleType>
     <xs:restriction base='xs:boolean'>
       <xs:pattern value='0|1' />
     </xs:restriction>
   </xs:simpleType>
  </xs:attribute>
  <xs:attribute name="actor" type="xs:anyURI" />

  <xs:simpleType name="encodingStyle" >
    <xs:annotation>
      <xs:documentation>
        'encodingStyle' indicates any canonicalization conventions followed in the contents of the containing element.  For example, the value 'http://schemas.xmlsoap.org/soap/encoding/' indicates the pattern described in SOAP specification
      </xs:documentation>
    </xs:annotation>
    <xs:list itemType="xs:anyURI" />
  </xs:simpleType>

  <xs:attribute name="encodingStyle" type="tns:encodingStyle" />
  <xs:attributeGroup name="encodingStyle" >
    <xs:attribute ref="tns:encodingStyle" />
  </xs:attributeGroup>

  <xs:element name="Fault" type="tns:Fault" />
  <xs:complexType name="Fault" final="extension" >
    <xs:annotation>
      <xs:documentation>
        Fault reporting structure
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="faultcode" type="xs:QName" />
      <xs:element name="faultstring" type="xs:string" />
      <xs:element name="faultactor" type="xs:anyURI" minOccurs="0" />
      <xs:element name="detail" type="tns:detail" minOccurs="0" />      
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="detail">
    <xs:sequence>
      <xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax" />
    </xs:sequence>
    <xs:anyAttribute namespace="##any" processContents="lax" /> 
  </xs:complexType>

</xs:schema>

使用任何programming languageAPIonline service,您可以根据给定的XSD手动或自动验证SOAP消息。

例如

就像我使用此在线服务(https://www.liquid-technologies.com/online-xsd-validator)一样,发现您的SOAP消息对模式有效。