C# SOAP-ERROR:编码:违反编码规则

C# SOAP-ERROR:编码:违反编码规则,c#,xml,web-services,soap,wsdl,C#,Xml,Web Services,Soap,Wsdl,我已经尽力了,现在我需要帮助。我试图使用一个支付网关web服务(),我得到了一个错误:“SOAP-error:编码:违反编码规则”。 问题是无论生成什么xml,都是由.NET生成的,如果xml无效或无效,我无法控制结果xml。从他们的文档中,他们希望XML类似于: <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> <Body> <Auth xmlns="urn:paygate.p

我已经尽力了,现在我需要帮助。我试图使用一个支付网关web服务(),我得到了一个错误:“SOAP-error:编码:违反编码规则”。 问题是无论生成什么xml,都是由.NET生成的,如果xml无效或无效,我无法控制结果xml。从他们的文档中,他们希望XML类似于:

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
   <Body>
     <Auth xmlns="urn:paygate.paybatch">
       <BatchReference>NewBatch1</BatchReference>
       <NotificationUrl></NotificationUrl>
       <BatchData>
            <BatchLine>A,INV01,Joe Soap,06a55ccf-d4fb-4f8a-9c3c-ad54c5f3b9c1,00,3299</BatchLine>
            <BatchLine>A,INV02,Mr Jones,13ab61b6-7c66-4d52-ae4f-13a472a168c2,12,15995</BatchLine>
       </BatchData>
     </Auth>
   </Body>
</Envelope>
请帮忙,我现在终于搜索了整个谷歌,不知道该怎么办了


提前感谢大家。

您尝试过指向外部模式“”的方法吗?@lloyd,我刚刚尝试过,XML似乎有效。记住,XML是由.NET生成的,我确信它至少是有效的XML。这不是客户所期望的!我不知道.NET为什么会产生这样的结果…@Morgs你知道paygate服务是asmx服务还是其他什么吗?添加服务引用时,是否尝试将其添加为web引用(添加服务引用-->单击高级-->单击添加web引用并指向WSDL)
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <q1:Auth xmlns:q1="urn:paygate.paybatch">
            <BatchReference xsi:type="xsd:string">d18001d3-4ab0-441d-849a-a3ad9d6405cb</BatchReference>
            <NotificationUrl xsi:type="xsd:string">http://www.website.com/PaygetNotify</NotificationUrl>
            <BatchData href="#id1"/>
        </q1:Auth>
        <q2:BatchData id="id1" xsi:type="q2:BatchData" xmlns:q2="urn:paygate.paybatch">
            <BatchLine href="#id2"/>
        </q2:BatchData>
        <q3:Array id="id2" q3:arrayType="xsd:string[1]" xmlns:q3="http://schemas.xmlsoap.org/soap/encoding/">
            <Item>A,d93b9710-92d1-4db2-ae6c-9aa158041498,Name 8 Surname 8,234569,00,6600</Item>
        </q3:Array>
    </s:Body>
</s:Envelope>
<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="PaybatchBinding">
                  <security mode="TransportWithMessageCredential">
                    <message clientCredentialType="UserName" />
                  </security>
                </binding>
                <binding name="PaybatchBinding1" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://secure.paygate.co.za/paybatch/process.trans"
                binding="basicHttpBinding" bindingConfiguration="PaybatchBinding"
                contract="PayGate.PaybatchPortType" name="paybatchPort" />
        </client>
    </system.serviceModel>
PaybatchPortTypeClient payget = new PaybatchPortTypeClient();

                payget.ClientCredentials.UserName.UserName = Variables.SystemRules.PaygateId;
                payget.ClientCredentials.UserName.Password = Variables.SystemRules.PaygatePsw;

BatchData batchData = new BatchData();
batchData.BatchLine = String[] {"A","d93b9710-92d1-4db2-ae6c-9aa158041498","Name 8 Surname 8","234569","00","6600"};
BatchReturn batchReturn = payget.Auth( "NewBatchId1", "http://www.website.com/PaygetNotify", batchData );