Link to home
Start Free TrialLog in
Avatar of jammy-d0dger
jammy-d0dger

asked on

How to submit HTTPS POSTs to external address and get response in XML

Hi Experts,

I'm trying to do an integration with the SagePay Reporting and Admin API but the documentation is pretty thin shall we say!

It 'sounds' like it should be easy but I've not done this before so any help much appreciated.  Basically the guide states:

"The API requests are HTTPS POSTs to the URLs above, containing a single FORM field called XML. It is important to note that these are not requests in XML format, but regular HTTPS POSTs with the content type “application/x-www-form-urlencoded” with the XML requests detailed below in a FORM field called XML.

The XML field will contain the XML message, which always takes the following format:
<vspaccess>
<command>whatever</command>
<vendor>Vendor Name</vendor>
<user>User name</user>
<other command specific parameters in here..../>
<signature>MD5 Hash Signature</signature>
</vspaccess>

The <signature> value is created by taking the rest of the contents of the <vspaccess> node, appending an element called <password> which contains the user account's password, and MD5 hashing the message. So in the above example:
MD5 Hash Signature =
MD5Hash(
"<command>whatever</command>
<vendor>VSP Vendor Name</vendor>
<user>User name</user>
<other command specific params in here..../>
<password>user password</password>")
The response format will always be a XML v1.0 ISO-8859-1 encoded document with a root node called <vspaccess>. i.e.:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<vspaccess>
<errorcode>nnnn</errorcode>
<error>Text error message if errorocode is not 0000</error>
<other command specific results here..../>
<timestamp>DD/MM/YY HH:MM:SS GMT</timestamp>
</vspaccess>

And that is all we get!  If someone more enlightened than me could please explain how I use this to create a form in ASP.NET 2.0 (i.e. can't use LINQ), to query the SagePay interface and how to then interpret the result, it would be much appreciated.  

Classic ASP may also be a useful solution.

Regards,

Jay
ASKER CERTIFIED SOLUTION
Avatar of G_H
G_H
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jammy-d0dger
jammy-d0dger

ASKER

Nice one, much appreciated.  I will give this a go tomorrow when back in the office, and let you know.
Avatar of Guy Hengel [angelIII / a3]
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.