1

我正在尝试对我的 Web 应用程序(C# .Net 4)实施 Adyen 定期付款,但对 Web 服务相对较新,我不确定我是否以正确的方式进行操作。

简而言之,支付提供商为此目的公开了一个 WSDL url (https://pal-test.adyen.com/pal/Recurring.wsdl),我在 Visual Studio 2010 中将其添加为服务参考(即添加服务参考>高级> 添加网页参考)

然后我继续创建了一个测试页面,以确保连接正常运行(参见下面的代码)并检索我之前创建的测试订阅的详细信息。但是,在执行“listRecurringDetails”操作时出现异常,错误消息是“对象引用未设置为对象的实例。”我不知道哪里出错了。

欢迎任何反馈。

#
public partial class Store_ServiceTest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Recurring proxy = new Recurring();
        ICredentials usrCreds = new NetworkCredential("[username]", "[password]");
        proxy.Credentials = usrCreds;

        try
        {
            RecurringDetailsRequest thisUserDetail = new RecurringDetailsRequest();
            thisUserDetail.merchantAccount = "[some reference]";
            thisUserDetail.shopperReference = "[some reference]";
            thisUserDetail.recurring.contract = "RECURRING";

            RecurringDetailsResult recContractDetails = proxy.listRecurringDetails(thisUserDetail);
            string createDate = recContractDetails.creationDate.ToString();
        }
        catch (Exception ex)
        {
            string err = ex.Message;
        }
        finally
        {
            proxy.Dispose();
        }        
    }
}
调用堆栈

App_Web_4h0noljo.dll!Store_ServiceTest.Page_Load(object sender, System.EventArgs e) 第 38 行 C#

输出窗口

mscorlib.dll 中发生“System.Threading.ThreadAbortException”类型的第一次机会异常 mscorlib.dll 中发生“System.Threading.ThreadAbortException”类型的异常但未在用户代码中处理 类型“System.在 App_Web_4h0noljo.dll 中发生 NullReferenceException' 线程 '' (0x15d0) 已退出,代码为 0 (0x0)。

4

1 回答 1

1

你的代码看起来不错。关键是将循环服务添加为服务引用而不是 Web 引用。如果应用程序配置文件包含以下内容,它应该可以工作:

<system.serviceModel>
 <bindings>
     <basicHttpBinding>
         <binding name="AdyenHttpBinding">
           <security mode="Transport">
             <message clientCredentialType="UserName"/>
             <transport clientCredentialType="Basic" realm="Adyen PAL Service Authentication"> <!--Adyen PAL Service Authentication-->
               <extendedProtectionPolicy policyEnforcement="Never"/>
             </transport>
           </security>
         </binding>
     </basicHttpBinding>
 </bindings>
 <client>
   <endpoint address="https://pal-test.adyen.com/pal/servlet/soap/Payment" binding="basicHttpBinding" bindingConfiguration="AdyenHttpBinding" contract="Adyen.Payment.PaymentPortType" name="PaymentHttpPort"/>
   <endpoint address="https://pal-test.adyen.com/pal/servlet/soap/Recurring" binding="basicHttpBinding" bindingConfiguration="AdyenHttpBinding" contract="Adyen.Recurring.RecurringPortType" name="RecurringHttpPort"/>
 </client>
</system.serviceModel>

亲切的问候, Sander Rasker (Adyen)

于 2012-11-14T13:10:40.317 回答