08-22-2018 09:05 AM - edited 03-14-2019 06:26 PM
Working on a script to collect customer data and send it to a URL. I am able to conduct the HTTP post to send the URL via create document. But i have a couple of questions:
1. When i send the HTTP Post, would i get a response back if i use a create XML document step?
2. I am anticipating on getting the response data in HTML Format below and was wondering how i can either format this to XML so i can collect and play "Auth=PRE7892" as the response to the end customer as a reference code.
HTML Format for Response:
<html>
<head>
<meta content="HTML Tidy for Java (vers. 26 Sep 2004), see www.w3.org" name="generator"/>
<title/>
</head>
<body><![CDATA[CoreID=54542734&REFNO=ACK956&Auth=PRE7892&SAVCode=B&BVN2ResponseMsg=M&Notes=&User1=123&User2=44&User3=22&User4=]]></body>
</html>
Solved! Go to Solution.
09-21-2018 10:28 AM
Based upon the data provided, I mocked up a Sample Response.
This sample script simulates the response (your data from the previous message) and assigns the parsed string of type array into string variables that can be used as responses to your callers query.
Let me know if this helps.
09-22-2018 12:35 PM
Thanks Sean. I was able to finally figuring out the way to receive the information. In 11.6, you are now able to use REST. So once i received the expected string as part of the response (Variable strBody), i now wrote a set step "Integer.parseInt(strBody.split ("&") [1].split("=")[1])" which essentially deletes everything else and passes me the transNr.
08-22-2018 05:01 PM
08-24-2018 08:54 AM
Yes i am definitely interested in collaborating. I figured i would use the Get XML Document to retrieve the information but then i am confused on how i can convert the information from a HTML looking response to XML.
I know worse case scenario, i will use substring to remove the information and only keep what i'm looking for but i was also thinking if they were any other methods such as using Keyword Transform and all.
08-24-2018 09:18 AM
I think you are on the right track. Try it out. Run it through the interactive step editor and see what the system does with the output of the step. Collect the document data from the "Create URL Doc - Post" step into a "Create XML Doc" step. Capture the output from the variable pane. It may already be formatting it in a way that can be parsed by the next "Get XML Document Data" step. If not, then, I think it will be the substring route...
IF possible, post the document output from the variable pane of the "Create XML" step.
-Sean
08-24-2018 09:50 AM
That's what i am doing right now. The problem becomes how do i format the get XML Document. Instead of using the normal XPATH like i would normally do, i am using the descendant method hoping to collect something so i can see at least how its formatted. So in this case i created in the XML Path area, i am putting in "/descendant:body" to output to my string called strBody. I am yet to run the test on this but when i do, i would let you know if it captures the data.
08-24-2018 11:24 AM
So the body portion of the HTML is the part you want to capture as a string.
I think the XPATH would look more like "//body" (based upon the original info you posted).
...that's if the document returned doesn't need more manipulation. That's why I asked if you would paste the data (in text) from the variable pane for the document output from the create xml doc step.
Not sure if this will work, and may need a different approach--but I wanted to follow the same line you were on, first.
-Sean
09-19-2018 07:37 AM
So I tested this in my lab and created a similar scenario. The response to the HTTP Get query is not returned in a XML parse-able format, but rather a standard HTML page. In looking at the data, I found that in my case, the data returned was consistent enough to convert the HTML data into a string and use the SPLIT function to parse the table data into an array. From there, I was able to use a loop and load the data into the desired result strings:
Example:
Now, I realize this is not exactly what the original request (above) was trying to solve, but the scripting is/could be similar.
Maybe this example will help someone with their process/requirement.
-Sean
09-19-2018 04:53 PM - edited 09-19-2018 04:56 PM
So attached is the script that has the URL part. If you run this URL on the software called POSTMAN, you will see the response. It doesnt quite come in HTML or XML. Its in JSON. I am still totally lost on how to get a response back. but if i run it in postman, i see the response and i do see it posting as well. I hope you can provide more options as to how i can get response back.
Here is what the response looks like
"ResponseCode=11&tranNr=0000414128123&PostDate=2017-10-14T11:33:53.000&Amount=000000001000&Auth=Lem10&SiteCode=&CWEResponse=&CABBResultCode="
09-20-2018 08:30 AM
09-21-2018 10:28 AM
Based upon the data provided, I mocked up a Sample Response.
This sample script simulates the response (your data from the previous message) and assigns the parsed string of type array into string variables that can be used as responses to your callers query.
Let me know if this helps.
09-22-2018 12:35 PM
Thanks Sean. I was able to finally figuring out the way to receive the information. In 11.6, you are now able to use REST. So once i received the expected string as part of the response (Variable strBody), i now wrote a set step "Integer.parseInt(strBody.split ("&") [1].split("=")[1])" which essentially deletes everything else and passes me the transNr.
09-22-2018 07:01 PM
09-19-2018 04:54 PM
By the ways, do you mind sending me the script you posted so i can see how you did it?
08-24-2018 09:44 AM
Yes i am definitely interested in collaborating. I figured i would use the Get XML Document to retrieve the information but then i am confused on how i can convert the information from a HTML looking response to XML.
I know worse case scenario, i will use substring to remove the information and only keep what i'm looking for but i was also thinking if they were any other methods such as using Keyword Transform and all.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide