在头元素中也添加soap信封的名称空间

时间:2019-06-21 06:37:17

标签: web-services soap xsd wsdl soa

标题##我还要在标题元素中添加soap信封的名称空间,以避免必须理解属性XML解析问题

我曾尝试在XSD中添加soapenv:mustUnderstand =“ false | true”,但没有运气。

<xsd:element name="httpRequestHeader" soapenv:mustUnderstand="false">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="Secret" type="xsd:string" minOccurs="0" nillable="true"/>
            <xsd:element name="Attribute1" type="xsd:string" minOccurs="0" nillable="true"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>

请在下面找到我的WSDL

<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions targetNamespace="http://www.myworld.com/myemp/Employee" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                  xmlns:tns="http://www.myworld.com/myemp/Employee"
                  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
                  xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <wsdl:types>
    <xsd:schema targetNamespace="http://www.myworld.com/myemp/Employee" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                attributeFormDefault="qualified" elementFormDefault="qualified">
      <xsd:element name="resquestICS">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="winID" type="xsd:string" minOccurs="1" nillable="false"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="responseICS">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="EE_WinID" type="xsd:string" minOccurs="0" nillable="true"/>
            <xsd:element name="EE_Name" type="xsd:string" minOccurs="0" nillable="true"/>
            <xsd:element name="EE_Status" type="xsd:string" minOccurs="0" nillable="true"/>
            <xsd:element name="EE_Email" type="xsd:string" minOccurs="0" nillable="true"/>
            <xsd:element name="Sup_Win" type="xsd:string" minOccurs="0" nillable="true"/>
            <xsd:element name="Sup_Email" type="xsd:string" minOccurs="0" nillable="true"/>
            <xsd:element name="Sup_Name" type="xsd:string" minOccurs="0" nillable="true"/>
            <xsd:element name="Attribute1" type="xsd:string" minOccurs="0" nillable="true"/>
            <xsd:element name="Attribute2" type="xsd:string" minOccurs="0" nillable="true"/>
            <xsd:element name="Attribute3" type="xsd:string" minOccurs="0" nillable="true"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="httpRequestHeader">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="Secret" type="xsd:string" minOccurs="0" nillable="true"/>
            <xsd:element name="Attribute1" type="xsd:string" minOccurs="0" nillable="true"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="httpResponseHeader">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="Secret" type="xsd:string" minOccurs="0" nillable="true"/>
            <xsd:element name="Status" type="xsd:string" minOccurs="0" nillable="true"/>
            <xsd:element name="Description" type="xsd:string" minOccurs="0" nillable="true"/>
            <xsd:element name="Attribute1" type="xsd:string" minOccurs="0" nillable="true"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="ResponseHeader" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <wsdl:part name="RespHeader" element="tns:httpResponseHeader"></wsdl:part>
  </wsdl:message>
  <wsdl:message name="RequestHeader">
    <wsdl:part name="ReqHeader" element="tns:httpRequestHeader"></wsdl:part>
  </wsdl:message>
  <wsdl:message name="ICSRequestMessage">
    <wsdl:part name="request" element="tns:resquestICS"></wsdl:part>
  </wsdl:message>
  <wsdl:message name="ICSResponseMessage">
    <wsdl:part name="response" element="tns:responseICS"></wsdl:part>
  </wsdl:message>
  <wsdl:portType name="EmployeeDetailsPortType">
    <wsdl:operation name="EmployeeDetails">
      <wsdl:input message="tns:ICSRequestMessage"></wsdl:input>
      <wsdl:output message="tns:ICSResponseMessage"></wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="EmployeeDetailsBinding" type="tns:EmployeeDetailsPortType">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="EmployeeDetails">
      <soap:operation soapAction=""/>
      <wsdl:input>
        <soap:header message="tns:RequestHeader" use="literal" part="ReqHeader"/>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:header message="tns:ResponseHeader" use="literal" part="RespHeader"/>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
</wsdl:definitions>

下面是SOAP响应:

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
   <env:Header>
      <tns:httpResponseHeader env:mustUnderstand="0" xmlns:tns="http://www.myworld.com/myemp/Employee">
         <tns:Secret>zvz</tns:Secret>
      </tns:httpResponseHeader>
   </env:Header>
   <env:Body>
      <tns:responseICS xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.myworld.com/myemp/Employee" xmlns:nstrgmpr="http://xmlns.oracle.com/types/GetEmployee/InboundSOAPResponseDocument" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
         <tns:EE_Name>vzvv</tns:EE_Name>
      </tns:responseICS>
   </env:Body>
</env:Envelope>

但是我想要下面的东西

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
   <env:Header>
      <tns:httpResponseHeader env:mustUnderstand="0" xmlns:tns="http://www.myworld.com/myemp/Employee" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
         <tns:Secret>zvz</tns:Secret>
      </tns:httpResponseHeader>
   </env:Header>
   <env:Body>
      <tns:responseICS xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.myworld.com/myemp/Employee" xmlns:nstrgmpr="http://xmlns.oracle.com/types/GetEmployee/InboundSOAPResponseDocument" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
         <tns:EE_Name>vzvv</tns:EE_Name>
      </tns:responseICS>
   </env:Body>
</env:Envelope>

即xmlns:env =“ http://schemas.xmlsoap.org/soap/envelope/”也要添加到标头-> tns:httpResponseHeader元素中 要么 从响应中删除必须理解的标记本身

0 个答案:

没有答案