Hi all,
again here.
Im new with web services consumption, hope some1 can help
I have followed this tutorial:
https://moxie4nav.wordpress.com/2015/09/10/call-external-web-service-using-new-cu-1290/
but I guess the wschool example is broken. Thats why im trying to use another from the internet. I get error in both, like xml is not well formed.
any ideas?
thanks!
//Url := 'http://www.w3schools.com/xml/tempconvert.asmx';
//url:='https://flairrugs.metapack.com/dm/services/ConsignmentTrackingService';
//reqText := '' + '10' +'';
url:='http://www.webservicex.net/ConvertTemperature.asmx?op=ConvertTemp';
//reqtext:='Temperature=50&FromUnit=degreeFahrenheit&ToUnit=degreeCelsius';
reqtext:='<Temperature>100</Temperature>'
+'<FromUnit>degreeCelsius</FromUnit>'
+'<ToUnit>degreeFahrenheit</ToUnit>';
// save request text in instream
TempBlob."Primary Key" := 1;
TempBlob.Blob.CREATEOUTSTREAM(ReqBodyOutStream);
ReqBodyOutStream.WRITE(reqText);
TempBlob.Blob.CREATEINSTREAM(ReqBodyInStream);
// run the WebServReqMgt functions to send the request
WebServReqMgt.SetGlobals(ReqBodyInStream,Url,Username,Password);
WebServReqMgt.DisableHttpsCheck;
WebServReqMgt.RUN;
// get the response
WebServReqMgt.GetResponseContent(RespBodyInStream);
ResponseXmlDoc := ResponseXmlDoc.XmlDocument;
ResponseXmlDoc.Load(RespBodyInStream);
MESSAGE(ResponseXmlDoc.InnerXml);
EDIT:
This is what im trying to do now, but I get error 500 (internal server error)
Any ideas how to debug? maybe is cos https?
Credential := Credential.NetworkCredential;
Credential.UserName := 'myusr';
Credential.Password := 'mypwd';
FindURL := '
https://mycomp.metasomething.com/dm/services/ConsignmentTrackingService?method=findParcelTrackingByConsignmentCode&consignmentCode=';
FindURL+='myitemcode';
HttpWebRequest := HttpWebRequest.Create(FindURL);
HttpWebRequest.Timeout := 30000;
HttpWebRequest.UseDefaultCredentials(FALSE);
HttpWebRequest.Credentials := Credential;
HttpWebRequest.Method := 'POST';
HttpWebRequest.ContentType := 'text/xml; charset=utf-8';
HttpWebRequest.Accept := 'text/xml';
MemoryStream := HttpWebRequest.GetRequestStream;
XMLRequestDoc := XMLRequestDoc.XmlDocument;
XMLRequestDoc.Save(MemoryStream);
MemoryStream.Flush;
MemoryStream.Close;
HttpWebResponse := HttpWebRequest.GetResponse;
IF HttpWebStatus.Equals(HttpWebResponse.StatusCode,HttpWebStatus.OK) THEN BEGIN
MemoryStream := HttpWebResponse.GetResponseStream;
XMLResponseDoc := XMLResponseDoc.XmlDocument;
XMLResponseDoc.Load(MemoryStream);
MemoryStream.Flush;
MemoryStream.Close;
Answers
The url https://www.w3schools.com/xml/tempconvert.asmx is working fine. You can check it via your browser directly.
The problem with CU1290 is that it does not understand SOAP 1.2. At least that is my understanding when I followed the same blog. So, if your web service version is 1.2 ... You can't consume it with CU1290
You can find useful comments in the same blog, some of them are mine
thanks for answering
https://www.w3schools.com/xml/tempconvert.asmx?op=CelsiusToFahrenheit
if you go there, enter value, you get error.
thats why I think does not work.
if it does not understand soap 1.2, why he made this example?
I solved my issue by creating a generic soap client. You can check my blog here http://navnab.wordpress.com/2016/12/05/dynamics-nav-generic-soap-client/
I hope this will help you.
Could you tell me if this is correct?
url:='http://www.webservicex.net/ConvertTemperature.asmx';
//reqtext:='Temperature=50&FromUnit=degreeFahrenheit&ToUnit=degreeCelsius';
reqtext:='<ConvertTemp xmlns="http://www.webserviceX.NET/">'
+'<Temperature>100</Temperature>'
+'<FromUnit>degreeCelsius</FromUnit>'
+'<ToUnit>degreeFahrenheit</ToUnit>';
im trying to run the previous example with another URL
Im still having the problem....
go to the main post of this thread, i have edited
Which problem do you face exactly?