3

我已经使用 Authorize.NET 的 GetCustomerProfile 很多年了,今天突然响应没有返回付款资料。它只返回一个配置文件数组,但所有重要字段(例如payment)都是空的。

(这是他们的 CIM 功能的一部分,其中返回了“混淆”的付款资料,应该类似于 XXXX1234)

我在 Visual Studio 中使用生成的代理到 URL https://api.authorize.net/soap/v1/Service.asmx?WSDL(生成 References.cs 文件)

4

2 回答 2

3

我在昨天 2015 年 11 月 3 日刚刚开始的 CreateCustomerPaymentProfile SOAP 调用(通过 .NET 自动生成的代理)上遇到了类似的问题,尽管我们已经成功连接 SOAP CIM 几年了。

我能够通过在 Visual Studio 中执行“更新服务参考”以根据其最新的 WSDL 重新生成代理类来“修复”该问题。WSDL 中有几处更改。

具体来说,在我看来,在他们成功创建后,响应似乎不包括 customerPaymentProfileId 的值。实际上,他们实际上仍在发送此值,但在 XML 响应中在其上方有一个新字段 customerProfileId。正如 Simon_Weaver 在他的回答中提到的那样,Visual Studio 生成的代理类具有正确反序列化所需的字段的明确排序。在已知字段上方添加这个以前的“未知”字段导致它破坏了我的代码。

幸运的是,这个新的 customerProfileId 包含在他们最新的 WSDL 中,因此“更新服务参考”和重新编译解决了我的问题。

我非常详细地告知 Authorize.net 支持我的问题,并告诉他们需要在 WSDL 文档的“序列”末尾包含任何新字段,以免破坏和客户端使用旧版本的 WSDL。到目前为止,我还没有收到他们的回复,但我鼓励其他遇到此问题的人,即使您已经解决了这个问题,也可以通过 support@authorize.net 向他们报告,以免他们意外再做一次。

于 2015-11-04T17:47:11.223 回答
1

好吧,你好西蒙!看起来 Authorize.NET 使用新字段更新了他们的服务,但忘记将它们添加到 WSDL。

这是我发送的示例请求(使用Fiddler拦截):

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPo3vYq2eC/5VIuiUcm2hEtw8AABBBJr/dLQF7z02Y7UKwphq24W1n9j0XlQ1MiAlOjy5fO14ACQAA</VsDebuggerCausalityData>
    </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <GetCustomerProfile xmlns="https://api.authorize.net/soap/v1/">
            <merchantAuthentication>
                <name>95U6bwXXXXX</name>
                <transactionKey>8tf62gV7XXXXXX</transactionKey>
            </merchantAuthentication>
            <customerProfileId>37745529</customerProfileId>
        </GetCustomerProfile>
    </s:Body>
</s:Envelope>

这是回应:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <GetCustomerProfileResponse xmlns="https://api.authorize.net/soap/v1/">
            <GetCustomerProfileResult>
                <resultCode>Ok</resultCode>
                <messages>
                    <MessagesTypeMessage>
                        <code>I00001</code>
                        <text>Successful.</text>
                    </MessagesTypeMessage>
                </messages>
                <profile>
                    <merchantCustomerId>33938</merchantCustomerId>
                    <email>4691705@EXAMPLE.COM</email>
                    <customerProfileId>37745529</customerProfileId>
                    <paymentProfiles>
                        <CustomerPaymentProfileMaskedType>
                            <billTo>
                                <firstName>TEST</firstName>
                                <lastName>USER</lastName>
                                <company>Defender Razor</company>
                                <address>1 RODEO DRIVE</address>
                                <city>BEVERLY HILLS</city>
                                <state>CA</state>
                                <zip>90210</zip>
                                <country>UNITED STATES</country>
                            </billTo>
                            <customerProfileId>0</customerProfileId>
                            <customerPaymentProfileId>34313485</customerPaymentProfileId>
                            <payment>
                                <creditCard>
                                    <cardNumber>XXXX5108</cardNumber>
                                    <expirationDate>XXXX</expirationDate>
                                </creditCard>
                            </payment>
                        </CustomerPaymentProfileMaskedType>
                    </paymentProfiles>
                </profile>
            </GetCustomerProfileResult>
        </GetCustomerProfileResponse>
    </soap:Body>
</soap:Envelope>

这里的一切都是正确的——你可以看到payment节点被正确发送。

但是 - 使用 .NET 反序列化,属性的顺序很重要 - 正如生成的References.cs文件中所指定的那样。

    [System.Xml.Serialization.XmlElementAttribute(Order=0)]

事实证明,响应中添加了两个新字段billTocustomerProfileId但并未将它们添加到 WSDL。

因此,当尝试反序列化该字段时,billTo会发现该字段,但这不是预期的 - 所以一切最终都为空。

如果您添加这两行(并小心地将它们添加到该类型中),那么您可以重新生成references.cs 文件(通过右键单击服务引用并重新生成文件)。

如果您从 URL 生成代理,https://api.authorize.net/soap/v1/Service.asmx?WSDL则需要在本地下载此文件Service.wsdl并从那里生成代理。

   <s:element minOccurs="1" maxOccurs="1" name="billTo" type="tns:CustomerAddressType"/>
   <s:element minOccurs="1" maxOccurs="1" name="customerProfileId" type="s:long" />

 <s:complexType name="CustomerPaymentProfileMaskedType">
    <s:complexContent mixed="false">
      <s:extension base="tns:CustomerPaymentProfileBaseType">
        <s:sequence>
          <s:element minOccurs="1" maxOccurs="1" name="billTo" type="tns:CustomerAddressType"/>
          <s:element minOccurs="1" maxOccurs="1" name="customerProfileId" type="s:long" />
          <s:element minOccurs="1" maxOccurs="1" name="customerPaymentProfileId" type="s:long" />
          <s:element minOccurs="0" maxOccurs="1" name="payment" type="tns:PaymentMaskedType" />
          <s:element minOccurs="0" maxOccurs="1" name="driversLicense" type="tns:DriversLicenseMaskedType" />
          <s:element minOccurs="0" maxOccurs="1" name="taxId" type="s:string" />
        </s:sequence>
      </s:extension>
    </s:complexContent>
  </s:complexType>

在检测到这一点之前,我损失了超过 12 小时的付款。幸运的是,我有客户的电子邮件,但这非常糟糕。您不能只在订单重要的响应中添加字段。更糟糕的是,您不能只是忘记将它们添加到 WSDL。

这对我来说是快速修复。我可能会在某个时候切换到使用正确的 API - 我已经向 Authorize.net 报告了这一点,希望他们也能做出回应。

这是我进行更改后 References.cs 中的差异。如您所见,该Order属性已增加:

在此处输入图像描述

于 2015-11-03T21:52:09.300 回答