我有这样的父母xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://tempuri.org/"
xmlns:ns2="http://schemas.datacontract.org/2004/07/Lia.Core.Models.Masterdata"
elementFormDefault="qualified" attributeFormDefault="qualified">
<xs:import namespace="http://schemas.datacontract.org/2004/07/Lia.Core.Models.Masterdata" schemaLocation="masterdataelements.xsd" />
<xs:element name="UploadCostCentres">
<xs:complexType>
<xs:sequence>
<xs:element name="costcentres" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="CostCentre" type="ns2:CostCentre" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="UploadCostCentresResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="status" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="message" type="xs:string" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
并且还有如下类型的导入xsd
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://schemas.datacontract.org/2004/07/Lia.Core.Models.Masterdata"
xmlns:tns="http://schemas.datacontract.org/2004/07/Lia.Core.Models.Masterdata"
elementFormDefault="qualified">
<xs:complexType name="CostCentre">
<xs:sequence>
<xs:element name="CompanyCode" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="CostCentreName" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="CostCentreNo" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="Division" type="xs:string" minOccurs="0"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="CostCentre" nillable="true" type="tns:CostCentre"/>
</xs:schema>
当我发送这样的soap请求时
<SOAP-ENV:Body>
<ns1:UploadCostCentres xmlns:ns1="http://tempuri.org/">
<ns1:costcentres>
<ns2:CostCentre xmlns:ns2="http://schemas.datacontract.org/2004/07/Lia.Core.Models.Masterdata">
<ns2:CompanyCode>6200</ns2:CompanyCode>
<ns2:CostCentreName>Med Trsf Ingst VD(SS</ns2:CostCentreName>
<ns2:CostCentreNo>0000063190</ns2:CostCentreNo>
<ns2:Division>SuperSport International</ns2:Division>
</ns2:CostCentre>
</ns1:costcentres>
</ns1:UploadCostCentres>
</SOAP-ENV:Body>
已解析上面的soap主体,但ns1:此列表元素具有空值
但如果我通过这样的请求
<SOAP-ENV:Body>
<ns1:UploadCostCentres xmlns:ns1="http://tempuri.org/">
<ns1:costcentres>
<ns1:CostCentre xmlns="http://schemas.datacontract.org/2004/07/Lia.Core.Models.Masterdata">
<CompanyCode>6200</CompanyCode>
<CostCentreName>Med Trsf Ingst VD(SS</CostCentreName>
<CostCentreNo>0000063190</CostCentreNo>
<Division>SuperSport International</Division>
</ns1:CostCentre>
</ns1:costcentres>
</ns1:UploadCostCentres>
</SOAP-ENV:Body>
然后它工作并传递正确的值。有人能告诉我如何使用嵌套的名称空间前缀。
暂无答案!
目前还没有任何答案,快来回答吧!