VS生成的WSDL命名空间问题

时间:2019-01-25 11:45:45

标签: c# xml namespaces wsdl

下午好,

我们一直在尝试使用Carrier API,但是在WSDL Generation方面遇到了一些问题。该公司提供的Example XML消息具有ns1-3,似乎对于地址字段很重要。从其WSDL生成的XML似乎会生成相同的字段,但没有像原始名称空间那样的名称空间,并且失败并显示“地址详细信息无效”,是否缺少某些设置以便生成正确的XML?

这是他们的示例XML

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <ns3:CreateLabel xmlns:ns3="http://courier.ck.dx.metafour.com/" xmlns:ns2="http://www.thedx.co.uk/eai/canonical/types/v2.0">
         <order>
            <ns2:customerID>14337622</ns2:customerID>
            <ns2:dates>
               <date format="yyyy-MM-dd HH:mm:ss" type="requestedCollectionDate">2018-12-12 17:59:21</date>
            </ns2:dates>
            <sourceSystemReference xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">AMS207554</sourceSystemReference>
            <customerReference xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">286956</customerReference>
            <orderAttributes xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0" xsi:nil="true" />
            <ns2:orderLines>
               <ns2:consignment>
                  <pieces>
                     <dimensions>
                        <value>1.0</value>
                        <type>cdlWeight</type>
                        <UOM>KG</UOM>
                     </dimensions>
                     <barcode xsi:nil="true" />
                     <trackingNumber xsi:nil="true" />
                  </pieces>
                  <qty>1</qty>
                  <legacyService>
                     <name>serviceLevel</name>
                     <partyId>0</partyId>
                     <partyType>HITS</partyType>
                  </legacyService>
                  <legacyService>
                     <name>serviceType</name>
                     <partyId>2</partyId>
                     <partyType>HITS</partyType>
                  </legacyService>
                  <deliverTo>
                     <ns2:address primary="true">
                        <organisationName>Argos</organisationName>
                        <addressLine1>Argos</addressLine1>
                        <addressLine2>Argos Ltd</addressLine2>
                        <addressLine3>11 Canning Street</addressLine3>
                        <city>BURNLEY</city>
                        <postalCode>BB12 0AD</postalCode>
                        <country>
                           <countryCode>GB</countryCode>
                           <description>GB</description>
                        </country>
                     </ns2:address>
                     <contact />
                  </deliverTo>
               </ns2:consignment>
            </ns2:orderLines>
            <labelType>ZPL</labelType>
         </order>
         <serviceHeader>
            <password>test</password>
            <userId>test</userId>
         </serviceHeader>
      </ns3:CreateLabel>
   </s:Body>
</s:Envelope>

这是我们生成的XML

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <CreateLabel xmlns="http://courier.ck.dx.metafour.com/">
         <order xmlns="">
            <customerID xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">14337622</customerID>
            <dates xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">
               <date xmlns="" format="yyyy-MM-dd HH:mm:ss" type="requestedCollectionDate">2019-01-25 10:17:33</date>
            </dates>
            <sourceSystemReference xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">AMS207554</sourceSystemReference>
            <customerReference xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">286956</customerReference>
            <orderAttributes xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0" xsi:nil="true" />
            <orderLines xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">
               <consignment>
                  <pieces xmlns="">
                     <dimensions>
                        <value>1.0</value>
                        <type>cdlWeight</type>
                        <UOM>KG</UOM>
                     </dimensions>
                     <barcode xsi:nil="true" />
                     <trackingNumber xsi:nil="true" />
                  </pieces>
                  <qty>1</qty>
                  <legacyService xmlns="">
                     <name>serviceLevel</name>
                     <partyId>0</partyId>
                     <partyType>HITS</partyType>
                  </legacyService>
                  <legacyService xmlns="">
                     <name>serviceType</name>
                     <partyId>2</partyId>
                     <partyType>HITS</partyType>
                  </legacyService>
                  <deliverTo xmlns="">
                     <address xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0">
                        <organisationName xmlns="">Argos</organisationName>
                        <addressLine1 xmlns="">Argos</addressLine1>
                        <addressLine2 xmlns="">Argos Ltd</addressLine2>
                        <addressLine3 xmlns="">11 Canning Street</addressLine3>
                        <city xmlns="">BURNLEY</city>
                        <postalCode xmlns="">BB12 0AD</postalCode>
                        <country xmlns="">
                           <countryCode>GB</countryCode>
                           <description>GB</description>
                        </country>
                     </address>
                     <contact xmlns="http://www.thedx.co.uk/eai/canonical/types/v2.0" />
                  </deliverTo>
               </consignment>
            </orderLines>
            <labelType>ZPL</labelType>
         </order>
         <serviceHeader xmlns="">
            <password>test</password>
            <userId>test</userId>
         </serviceHeader>
      </CreateLabel>
   </s:Body>
</s:Envelope>

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:0)

此问题已解决

我无法找到一种方法来更改或向生成的references.cs文件添加其他名称空间,并最终使用通过httpWebRequest和XmlSerializer序列化的XML字符串将SOAP手动发送到其服务器。