Reputation: 89
I am working on making an existing small website compatible with the Ariba punchout.
I can read the incoming setup, do a response and then redirect them to a valid login back to the website.
On the Ariba punchout tester, this all works correctly and can add items to the cart.
I am attempting to complete the process and send the PunchOutOrderMessage back to the cart.
In the cXML documentation example, it has the following format:
<input type="hidden" name="cxml-urlencoded" value="<!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.014/cXML.dtd">
.... etc
I have configured the same message, but with the correct details for the cart punchout.
I am at a loss though how to get it to send back to the Ariba site. Doing the punchout provides the Form POST URL, which I am supposed to send the form back to.
I tried the methods from here: How to make HTTP POST web request to connect to the web server, but wasn't sure what to do with the message. I have just loaded it in as text:
ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(ValidateRemoteCertificate);
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var content = new StringContent(strPost);
var response = await client.PostAsync(PostURL, content);
var responseString = await response.Content.ReadAsStringAsync();
Checking the ResponseString just provides a full web page from Ariba, as if I had just gone to the site manually.
The embedded browser just stays open on the punchout site and doesn't go anywhere.
Has anybody had any success connecting back to the Ariba site and posting an order?
Upvotes: 2
Views: 4342
Reputation: 91
The PunchOutOrderMessage document should be sent back to Ariba client-side not server-side. This can be done by putting the cXML in a hidden input field of a <form>
and submitting the form using JavaScript. Also, make sure the cXML is HTML escaped in the value of the input field.
Example HTML/JavaScript for this case can be found here: https://punchoutcommerce.com/guides/punchout/cxml-punchout-order-message/#cart_transmission
Upvotes: 2
Reputation: 179
I came across this while looking for an answer to my own question about the step after this, but better late than never.
This worked for me (HOOK_URL is the URL provided by Ariba) - keep your service point manager code :
byte[] response = Encoding.ASCII.GetBytes(output);
var request = (HttpWebRequest)WebRequest.Create(poom.HOOK_URL);
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
try
{
request.GetRequestStream().Write(response, 0, response.Length);
}
catch (Exception ex)
{
LogHelpers.Write(log, ex);
}
WebResponse webresponse = null;
try
{
webresponse = request.GetResponse();
}
catch (Exception ex)
{
LogHelpers.Write(log, ex);
}
My problem is what to do with their response, which is a short script (<script>) block which redirects the top.location.href to another page. Problem is, it's a relative URL so it tries to redirect to that URL on my site. So I'll keep searching, but hopefully this will help someone else.
Upvotes: 1