asp.net-mvc-3 - MVC Paypal 助手错误 : PayPal. Platform.SDK.FATALException

标签 asp.net-mvc-3 paypal

我正在使用 PayPal 助手 http://paypalhelper.codeplex.com并且出现错误 PayPal.Platform.SDK.FATALException

在那之后,我也查看了源代码,看看那里发生了什么,在我调试测试项目 public void TestImplicitSimplePay() 中的一个测试后,发现它抛出了一个错误在 SoapEncoder 方法中 Decode96 return (object)serializer.Deserialize(reader);

public static object Decode(string soapEnvelope, Type toType)
        {
            XmlSerializer serializer = null;

            try
            {
                /// Initializing the XMLSerializer.
                serializer = new XmlSerializer(toType);

                /// Removing SOAP outer Envelope
                soapEnvelope = soapEnvelope.Replace("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header /><soapenv:Body>", string.Empty);
                soapEnvelope = soapEnvelope.Replace("</soapenv:Body></soapenv:Envelope>", string.Empty);
                soapEnvelope = soapEnvelope.Replace("xmlns:ns2=\"http://svcs.paypal.com/types/ap\"", string.Empty);
                soapEnvelope = soapEnvelope.Replace("ns2:", string.Empty);
                soapEnvelope = soapEnvelope.Replace("soapenv:", string.Empty);
                soapEnvelope = soapEnvelope.Replace("ns3:", string.Empty);
                soapEnvelope = soapEnvelope.Replace("xmlns:ns2=\"http://svcs.paypal.com/types/ap\"", string.Empty);

                /// Deserializing and Returning the XML
                using (MemoryStream reader = new MemoryStream(Encoding.UTF8.GetBytes(soapEnvelope)))
                {
                    return (object)serializer.Deserialize(reader); //Error here
                }                
            }
            catch (FATALException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new FATALException("Error occurred in SoapEncoder->Decode method", ex);
            }
            finally
            {
                serializer = null;
            }
        }

肥皂信封 xml:

<xml version='1.0' encoding='utf-8'?>
    <Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">
        <Header/>
        <Body>
            <PayResponse >
                <responseEnvelope>
                    <timestamp>2011-08-09T00:28:53.399-07:00</timestamp>
                    <ack>Success</ack>
                    <correlationId>621854fd57929</correlationId>
                    <build>2012864</build>
                </responseEnvelope>
                <payKey>AP-1SE162159L922805T</payKey>
                <paymentExecStatus>COMPLETED</paymentExecStatus>
        </PayResponse>

可能有人遇到过这个问题并知道我能做些什么来解决这个问题?

最佳答案

替换这一行:

soapEnvelope = soapEnvelope.Replace("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header /><soapenv:Body>", string.Empty);

与:

soapEnvelope = soapEnvelope.Replace("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header/><soapenv:Body>", string.Empty);

Paypal 的响应似乎略有变化,<soapenv:Header />节点在自闭标签结束前不再有空格。

关于asp.net-mvc-3 - MVC Paypal 助手错误 : PayPal. Platform.SDK.FATALException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6992715/

相关文章:

paypal - 我们可以将样式应用于上下文窗口吗?

paypal - 在不符合 PCI 的情况下保存信用卡

c# - MVC3 maproute 不显示操作?

asp.net-mvc-3 - 通过 Ajax 在 ASP.NET MVC3 中上传文件不起作用

c# - 如何在 C# 中的 ActionLink html 帮助程序中指定 Controller

asp.net-mvc-3 - 如何在 ASP.NET MVC 上禁用 TRACE Http 方法

sql-server-2005 - 多主键与 asp .net mvc 3

Paypal 缺少带有 Orders API V2/Sandbox 的付款人地址

payment-gateway - 集成paypal支付专业版

paypal - SetExpressCheckout和DoExpressCheckoutPayment中的PAYMENTREQUEST_n_AMT是什么意思?