I was using PayPal helper http://paypalhelper.codeplex.com and was getting an error PayPal.Platform.SDK.FATALException
After that i took the source code too have look what is happening there and after i debug one of the tests in the test project public void TestImplicitSimplePay()
and find out that it is throwing an error in the class SoapEncoder
in method Decode
in line 96 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;
}
}
soapEnvelope 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>
May be some one come across that and know what i can do to fix that?
Replace this line:
soapEnvelope = soapEnvelope.Replace("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header /><soapenv:Body>", string.Empty);
With:
soapEnvelope = soapEnvelope.Replace("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header/><soapenv:Body>", string.Empty);
The response from Paypal seems to have altered slightly and the <soapenv:Header />
node no longer has a space before the self closing tag ends.
精彩评论