c# - VS 生成的 WSDL 命名空间问题

标签 c# xml namespaces wsdl

下午好,

我们一直在尝试使用 Carrier API,但在 WSDL Generation 中遇到了一些问题。公司提供的示例 XML 消息具有 ns1-3 并且似乎对地址字段很重要。从他们的 WSDL 生成的 XML 似乎生成了相同的字段,但没有像原始字段那样的 namespace ,并且失败并显示“地址详细信息无效”,我们是否缺少某些设置以便生成正确的 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>

任何帮助将不胜感激!

最佳答案

这个解决了,

我想不出一种方法来更改或添加额外的命名空间到生成的references.cs 文件,并最终使用使用 httpWebRequest 和 XmlSerializer 序列化的 XML 字符串手动将 SOAP 发送到他们的服务器

关于c# - VS 生成的 WSDL 命名空间问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54364708/

相关文章:

c++ 命名空间分辨率 ("automatic using"基于参数?)

具有多个类的 C++ 共享库

c++ - C++中嵌套函数声明的范围

c# - 通过方法调用将自定义对象传递给 DLL

c# - Linq/C# 从联结表中获取信息

c# - for循环进入0% cpu hang

安卓 : edittext alert

R:巨大(> 20GB)文件的xmlEventParse期间的内存管理

c# - 如何在 visual studio 2013 解决方案资源管理器中获取文件路径?

sql - 如何更新 SQL Server 表中现有的 XML 字段数据?