AnsweredAssumed Answered

Calling a Boomi REST web service from C# code

Question asked by allan.ford577519 on Aug 29, 2017
Latest reply on Aug 29, 2017 by allan.ford577519

Hi ! - I wondered if anyone would be willing to share example C# code on calling a Boomi REST web service from a C# application ?   I know how to call a SOAP web service from C# e.g. as per this code example, but I am interested in calling a REST web service ..

 

C# example calling SOAP web service:

 

HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(@"http://awsuxboomi01t:9090/ws/soap");
webRequest.Headers.Add(@"SOAP:Action");
webRequest.ContentType = "text/xml;charset=\"utf-8\"";
webRequest.Accept = "text/xml";
webRequest.Method = "POST";

XmlDocument soapEnvelopeXml = new XmlDocument();
soapEnvelopeXml.LoadXml(@"<?xml version=""1.0"" encoding=""utf-8""?>
<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:wss=""http://www.boomi.com/connector/wss"">
<soapenv:Header/>
<soapenv:Body>
<wss:getWell_information>
<!--Optional:-->
<element>
<!--Optional:-->
<well_code>7</well_code>
</element>
</wss:getWell_information>
</soapenv:Body>
</soapenv:Envelope>"
);
using (Stream stream = webRequest.GetRequestStream())
{
soapEnvelopeXml.Save(stream);
}
using (WebResponse response = webRequest.GetResponse())
{
using (StreamReader rd = new StreamReader(response.GetResponseStream()))
{
string soapResult = rd.ReadToEnd();
MessageBox.Show(soapResult);
}
}

 

 

 

Regarding C# app calling a REST web service, I have tried C# code like this:

 

 

string url = "http://awsuxboomi01t:9090/ws/simple/getHello_information?hello_information=%22ABC%22";
HttpWebRequest GETRequest = (HttpWebRequest)WebRequest.Create(url);
GETRequest.Method = "GET";
MessageBox.Show("Sending GET Request");
HttpWebResponse GETResponse = (HttpWebResponse)GETRequest.GetResponse();
Stream GETResponseStream = GETResponse.GetResponseStream();
StreamReader sr = new StreamReader(GETResponseStream);

MessageBox.Show("Response from Server");
MessageBox.Show(sr.ReadToEnd());

 

 

but I get error returned:

 

(405) Method Not Allowed.

 

hmmm...

Outcomes