After doing some investigation and reading several posts about it and in particular this one :
I came up with the following code:
RequestingXMLData = @"<?xml version=""1.0"" encoding=""UTF-8""?>
<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:urn=""urn:iaso-com:cloud:mansvc:15.12.0"">
<soapenv:Header/>
<soapenv:Body>
<urn:Authenticate>
<request>
<partnerName>XXX</partnerName>
<userName>XXX</userName>
<password>XXX</password>
</request>
</urn:Authenticate>
</soapenv:Body>
</soapenv:Envelope>";
//Retrieves XML Data from API link / service, optional to spit XML to a given file location
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ApiCallPath);
request.Method = "POST";
request.ContentType = "text/xml;charset=\"utf-8\"";
request.ContentLength = RequestingXMLData.Length;
using (Stream webStream = request.GetRequestStream())
using (StreamWriter requestWriter = new StreamWriter(webStream, System.Text.Encoding.ASCII))
{
requestWriter.Write(RequestingXMLData);
}
try
{
WebResponse webResponse = request.GetResponse();
using (Stream webStream = webResponse.GetResponseStream())
{
if (webStream != null)
{
using (StreamReader responseReader = new StreamReader(webStream))
{
response = responseReader.ReadToEnd();
}
}
}
}
catch (WebException e)
{
var resp = new StreamReader(e.Response.GetResponseStream()).ReadToEnd();
}
return response;
I keep getting the 500 error at the WebResponse webResponse = request.GetResponse();
part.
As suggested in several posts I downloaded Fiddler and the response I get from it looks fine (Not experienced with it though so I could be off):
Request Count: 1
Bytes Sent: 85 (headers:85; body:0)
Bytes Received: 107 (headers:107; body:0)
Tunnel Sent: 1.740
Tunnel Received: 4.900
ACTUAL PERFORMANCE
--------------
ClientConnected: 11:03:28.895
ClientBeginRequest: 11:03:28.900
GotRequestHeaders: 11:03:28.900
ClientDoneRequest: 11:03:28.901
Determine Gateway: 0ms
DNS Lookup: 0ms
TCP/IP Connect: 12ms
HTTPS Handshake: 0ms
ServerConnected: 11:03:28.916
FiddlerBeginRequest: 11:03:28.916
ServerGotRequest: 11:03:28.916
ServerBeginResponse: 00:00:00.000
GotResponseHeaders: 00:00:00.000
ServerDoneResponse: 00:00:00.000
ClientBeginResponse: 11:03:28.917
ClientDoneResponse: 11:03:28.917
Overall Elapsed: 0:00:00.017
RESPONSE BYTES (by Content-Type)
--------------
~headers~: 107
Next thing I did was trying to retrieve the WebException and this is what it is returning:
I also tested it in SOAP UI and there it seems to work - after fixing a Java error (so the authenticate data is correct as well).
Some additional info:
- SOAP link called = https://cloud.iaso.com/manserv
- API information https://www.iaso.com/kb/article.php?url=IASOARTICLE38 (which I find quite hard to read/understand.
Keep in mind that I never done something before with SOAP, so my apologies if the problem seems obvious :)