我已尽力而为,现在我需要帮助。我正在尝试使用支付网关Web服务(Payget WSDL),我收到错误:“SOAP-ERROR:编码:违反编码规则”。 问题是生成的xml是什么,是由.NET生成的,如果它无效,我就无法控制结果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>
但是,当我发出请求时,.NET生成的输出xml如下所示:
<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>
正如您所看到的,预期的xml与.NET生成的xml存在差异。这可能是我收到错误的原因吗?有没有办法让.NET按照wsdl规范的预期生成xml?难道我做错了什么? 下面是wsdl的app.config:
<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>
我添加了服务引用正常的右键单击添加服务引用,Visual Studio自动生成所有内容。以下是我提出请求的方式:
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 );
请任何帮助都会有所帮助,我现在终于谷歌搜索了整个谷歌而不做该做什么。
提前感谢所有人。