Asp.net 使用.Net访问Adyen web服务

Asp.net 使用.Net访问Adyen web服务,asp.net,web-services,soap,wsdl,Asp.net,Web Services,Soap,Wsdl,我正在尝试在我的web应用程序(C#.Net 4)中实现Adyen定期支付,但由于对web服务比较陌生,我不确定我是否正确地使用了这种方式 简而言之,支付提供者为此目的公开了一个WSDL url(https://pal-test.adyen.com/pal/Recurring.wsdl)我在VisualStudio2010中将其添加为服务参考(即添加服务参考>高级>添加Web参考) 然后,我继续创建了一个测试页面,以确保连接是可操作的(请参见下面的代码),并检索我之前创建的测试订阅的详细信息。但

我正在尝试在我的web应用程序(C#.Net 4)中实现Adyen定期支付,但由于对web服务比较陌生,我不确定我是否正确地使用了这种方式

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

然后,我继续创建了一个测试页面,以确保连接是可操作的(请参见下面的代码),并检索我之前创建的测试订阅的详细信息。但是,当执行'listRecurringDetails'操作时,我遇到了一个异常,错误消息是'Object reference not set to a instance of a Object'。我无法判断哪里出了问题

欢迎任何反馈

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(对象发送方,System.EventArgs e)第38行C#

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

您的代码看起来不错。关键是将定期服务添加为 服务引用而不是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)

您的代码看起来不错。关键是将定期服务添加为 服务引用而不是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>

亲切问候,,
桑德·拉斯克(阿德扬)

调试器说了什么?请发布stacktrace.Hi Tomas。谢谢你的评论。调用堆栈似乎没有显示太多,因此我也添加了输出窗口的内容。让我知道你的想法。Thx调试器说了什么?请发布stacktrace.Hi Tomas。谢谢你的评论。调用堆栈似乎没有显示太多我还添加了输出窗口的内容。请告诉我您的想法。感谢您的帮助Sander。添加对web配置的引用也是一个很好的举措!关于thisUserDetail.Recurrency.contract=“Recurrential”的快速说明“为了指出这仍在生成“对象引用未设置为对象实例”错误,因此我采纳了您的建议thisUserDetail.Recurrency=new Adyen.Recurrency(){contract=“Recurrency”};这就成功了;-)当我添加服务引用时,它需要一些用户名和密码。我怎样才能拿到这些证件谢谢你的帮助Sander。添加对web配置的引用也是一个很好的举动!关于thisUserDetail.Recurrential.contract=“Recurrential”的快速说明,指出这仍在生成“对象引用未设置为对象实例”错误,因此我选择了您的建议thisUserDetail.Recurrential=new Adyen.Recurrential(){contract=“Recurrential”};这就成功了;-)当我添加服务引用时,它需要一些用户名和密码。我怎样才能得到这些证书