Consuming REST services in OpenSpan
This topic is about consuming REST web services in OpenSpan.
Problem Statement
Process to be automated involves REST service calls to retrieve data from a website.
OpenSpan only supports WSDL services and therefore calls for creating a custom component that can be integrated with OpenSpan.
Solution
Creation of C# based custom component that takes 3 parameters namely URL, Method and Body
and output the JSON string result. This result can be further parsed by converting it into XML and later on iterating through the required nodes.
Automation Logic
Calling Rest Web Service via C#
public void CreateObject(string _URL, string _BODY, string _method, out string response)
{
string URL = _URL.Trim();
string DATA = _BODY.Trim();
response=string.Empty;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
request.Method = _method;
request.ContentType = "application/json";
request.ContentLength = DATA.Length;
using (Stream webStream = request.GetRequestStream())
using (StreamWriter requestWriter = new StreamWriter(webStream, System.Text.Encoding.ASCII))
{
requestWriter.Write(DATA);
}
try
{
WebResponse webResponse = request.GetResponse();
using (Stream webStream = webResponse.GetResponseStream())
{
if (webStream != null)
{
using (StreamReader responseReader = new StreamReader(webStream))
{
response = responseReader.ReadToEnd();
}
}
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
Converting JSON string into XML
Namespace
Required:
using Newtonsoft.Json;
public string
ConvertJsonToXML(string json)
{
XNode node =
JsonConvert.DeserializeXNode(json, "Root");
return node.ToString();
}
Good post! Thanks for sharing this Information.The information you Provided is much useful onopenspan online classes
ReplyDeleteI have to voice my passion for your kindness giving support to those people that should have guidance on this important matter.Online training in USA
ReplyDeleteThanks for sharing this Blog. It was nice to read.RPA Training in Irving
ReplyDeleteHello all !! You may be way behind if you are not learning RPA, enroll here for the course: https://bit.ly/2NAxcMd
ReplyDeleteVery good post about Robotic process Automation (RPA) . The information you provided in the post is very helpful and useful. Keep posting.
ReplyDeleteCheers
RPA Training in Chennai\
It's really a nice experience to read your post. Thank you for sharing this useful information. If you are looking for more about Business Intelligence, Big Data Management, big data consulting services then kindly just move to http://muoro.io/
ReplyDeleteHi Sir, I am regular to your site.
ReplyDeleteCan you please update few more topics in ur freetime.
This comment has been removed by the author.
ReplyDeleteIf you're looking for regular updates on .net programming tech and Robotics process automation,you could keep a watch on websites like http://www.dotnetbasic.com
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteIf you're looking for regular updates on .net programming tech and Robotics process automation,you could keep a watch on below website.
ReplyDeleteComplete Dot net and RPA tutorials
Thanks for nice article you shared.
ReplyDeleteComplete Dot net and RPA tutorials
Thank u for sharing information...this blog is really informative and useful for us...please keep it up..for more information please visit
ReplyDeletehttps://www.kausalvikash.in/blog/cognitive-rpa-and-the-need-for-the-change/
Thanks for sharing this valuable Information
ReplyDeleteRPA Training in Pune
It should be noted that whilst ordering papers for sale at paper writing service, you can get unkind attitude. In case you feel that the bureau is trying to cheat you, don't buy term paper from it. security company
ReplyDeletenice article thank you for sharing this article for more information in rpa online training visit www.jayitsolutions.com
ReplyDeleteUseful Information..!!! Best blog with effective information’s..!!
ReplyDeleteRPA course in Chennai
Android Course in Chennai
Angularjs course in Chennai
.net coaching centre in chennai
Hacking Course in Chennai
Digital Marketing Training in Chennai