PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV Mobile 2024 → WM19 HTTPREQUEST
WM19 HTTPREQUEST
Started by Dave Summers, Jan., 08 2016 11:54 AM - 2 replies
Posted on January, 08 2016 - 11:54 AM
Hi

I am trying to make a REST webservice call passing an XML within the message.

In WD19 i get a correct XML response as expected first time BUT in WM19 i get 'error has occurred' in the XML response

Both calls are using the same code :-

sSendMessage is string
bufResult is Buffer

sSendMessage = "<r id=""HH1"" t="""" ts=""1974-07-15 18:35:59.000000+00:00"">"+CR
sSendMessage += "<d>"+CR
sSendMessage += "<c n=""UserName"">DbisAdmin</c>"+CR
sSendMessage += "<c n=""Password"">Test</c>"+CR
sSendMessage += "</d>"+CR
sSendMessage += "</r>"+CR



IF HTTPRequest("https://<url>/","","",sSendMessage,"text/xml","","")
bufResult = UTF8ToString(HTTPGetResult(httpResult))
Info(bufResult)
ELSE
Error(ErrorInfo())
END

Any help would be greatly appreciated

Many thanks
Dave
Posted on January, 08 2016 - 1:44 PM
Hi Dave,

In WM, a variable defined as string is UNICODE by default, so you are
sending a unicode message to the web service and the webservice is
clearly waiting for an ANSI string


Best practice is to ALWAYS declare variable EXPLICITELY as ANSI string
or UNICODE string, depending on your needs

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM
(open source)

More information on http://www.fabriceharari.com


On 1/8/2016 5:54 AM, Dave Summers wrote:
Hi

I am trying to make a REST webservice call passing an XML within the
message.
In WD19 i get a correct XML response as expected first time BUT in WM19
i get 'error has occurred' in the XML response

Both calls are using the same code :-

sSendMessage is string
bufResult is Buffer

sSendMessage = "<r id=""HH1"" t="""" ts=""1974-07-15
18:35:59.000000+00:00"">"+CR
sSendMessage += "<d>"+CR
sSendMessage += "<c n=""UserName"">DbisAdmin</c>"+CR
sSendMessage += "<c n=""Password"">Test</c>"+CR
sSendMessage += "</d>"+CR
sSendMessage += "</r>"+CR



IF HTTPRequest("https://<url>/","","",sSendMessage,"text/xml","","")
bufResult = UTF8ToString(HTTPGetResult(httpResult))
Info(bufResult)
ELSE
Error(ErrorInfo())
END

Any help would be greatly appreciated

Many thanks
Dave
Posted on January, 08 2016 - 3:38 PM
Fabrice

Your an absolute star as always, what would this forum do without you

problem solved - needed to be set ANSII as you suggested

Many thanks for your help

Dave