Error making order with Secure Paging API

Asked

Viewed 759 times

3

When trying to create the payment, I get the following error. I am using the following package: https://www.nuget.org/packages/Uol.PagSeguro

Additional information: For security reasons, the DTD is prohibited in this XML document. To enable DTD processing, set the Dtdprocessing property in Xmlreadersettings as Parse and pass the settings for the Xmlreader.Create method.

I’m using a test code offered by Gypsy in this topic:

The exception is raised in the following line:

var paymentRedirectUri = payment.Register(credentials);

I’m also using the environment sandbox of Pagseguro, and I’ve checked the credentials and the sent URL (before was giving error 401).

I can get around the error described above by editing the API code in the following code block:

XmlReaderSettings settings = new XmlReaderSettings();
settings.ProhibitDtd = false;
using (XmlReader reader =     XmlReader.Create(response.GetResponseStream(), settings))
{
  //Codigo pagseguro
}

However, when making this change, I get the following error when the API reads XML

Additional information: Invalid character in the provided encoding. Line 20, heading 48.

  • Give more information on how you are doing.

  • Updated question. Is there any other information I can give that is useful?

  • 1

    I don’t know why I don’t understand the subject, but I know that showing only the error doesn’t help much. It’s always good to put what you’ve done.

  • What has been accomplished is exactly what is in the question answered by Gypsy. The code is even the same, only for testing the integration of the API. However, this error is emerging.

1 answer

0


Invalid character, this sounds like an XML that works with ANSI (or iso-8859-1/window-1252) but end up returning data with characters UTF-8, is just a theory, but maybe you should check the encodings returned by XML. To do this check try to analyze the content of response.GetResponseStream().

Note that if your XML uses UTF-8 (or other UNICODE encoding) and the header does not have something like <?xml charset="UTF-8" ?> this error is likely to occur.

If the document has equivalent characters of latin1 and there is no charset defined to iso-8859-1 or windows-1252, this error may also occur.

Analyzing the user code Gypsy, I found nothing related to XmlReader that you quoted, so I’ll assume this is an application of yours.

An anternative solution would be to use this property:

public bool CheckCharacters { get; set; }

Defining as false the XmlReaderSettings.CheckCharacters you will uncheck the character check.

Follows documentation:

http://msdn.microsoft.com/en-us/library/system.xml.xmlreadersettings.checkcharacters%28v=vs.110%29.aspx

Browser other questions tagged

You are not signed in. Login or sign up in order to post.