I am having trouble interpreting the response data from an OpenEdge.Net.HTTP.IHttpRequest. The request itself executes as expected and performs it's function.
The problem is that the response object (OpenEdge.Net.HTTP.IHttpResponse) has the correct ContentLength/StatusCode/StatusReason but the Entity and ContentType fields are ? and blank respectively.
cURL = "http://SomeURL/SomeService":U
oXML = NEW STRING(lcXML)
oURI = URI:Parse(cURL).
oLib = ClientLibraryBuilder:Build():sslVerifyHost(NO):Library
oRequest = RequestBuilder:Post(oURi,oXML):AcceptAll():ContentType('application/x-www-form-urlencoded'):Request
oResponse = ClientBuilder:Build():UsingLibrary(oLib):Client:Execute(oRequest)
oEntity = oResponse:Entity.
oResponse:Entity is ? and i'm unable to do anything with it. I have run my routine with:
log-manager:logfile-name = "MyLog.log".
log-manager:logging-level = 6.
And I can see that the response-data-chunk contains the data i am looking for from the httpresonse. I am expecting XML as the response data, for what it's worth.
Any ideas where I am going wrong?
I have spent some more time working on this and come up with a solution, of sorts, but am failing to understand why it works and my above solution does not. If anyone could shed some light I'd appreciate so i understand better going forward (or anyone else has this issue).
First a little more information, in case it's relevant. I am running version 11.6 SP 3 and the service I am trying to call is a third-party SOAP web service that requires an XML document passed to it and responds in kind with an XML document.
Running the same request as my original post through POSTMAN or SOAPUI is successful.
In the end i managed to get it working in my program by opting to use the System.Net.WebClient instead of OpenEdge.Net.HTTP.
Here is the code I am using (successful), it is my understanding that this should not be functionally different from the above?
/**** Code ****/
/* lcXML is a longchar generated by write-xml and webResponse is a longchar */
cURL = "http://Site/Service".
FIX-CODEPAGE(webResponse) = "UTF-8".
HttpClient = NEW System.Net.WebClient().
webResponse = HttpClient:UploadString(curl,"xmlRequest=":U + lcXML).
DELETE OBJECT HttpClient.
MESSAGE WebResponse VIEW-AS ALERT-BOX. /* Success! */
Hope this helps if anyone is having the same problem. Hopefully someone can explain where I am going wrong.
Originally I had wanted to use the http options afforded by version 11.6 since it was just a simple post operation.
I did actually run the bprowsdldoc utility and attempt to get it work using the stubs provided but was still unable to get the response correctly. The request function seemed to resolve correctly but I would get an error saying:
"Error receiving Web Service Response: Version Mismatch. 'createResult:(null)' is not supported SOAP Envelope".
The wsdl doc itself contains namespaces for both SOAP 1.1 and 1.2 so I am unsure what exactly needs to be done about this error. The stubs provided by the bprowsdldoc utility don't specify how to get the response (can only be run as a procedure and has no output param).
Is there any reason not to use http methods as opposed to this?
I have just tried running it with the parameter you suggested and, indeed, it does show quite different results. Using this method I can see that it specifies an output parameter to get the response data (not sure why I don't get this without -show100style) and using the ns0 namespace as you suggest seems to help.
I am still getting an error but I think that's because I haven't yet got to figuring out how to set the content-type to the required value using this method. I'll play with this a bit more when I get time and see if it works with the correct content-type.
I will probably just use the system.net.webclient method for the time being since it's working correctly and is simpler to implement. I just don't understand why this works but my first example doesn't...
Thanks for your assistance.
Couple of things
- are you catching errors? if so, are there any?
- if you look at the response-data-received.txt does it contain what you expect? note that there may be a bunch of (expected) null characters
- are there any errors /oddities in the MyLog.log file?
I am catching errors but not getting any.
The response-data-received.txt does have the correct data I believe (the XML is in there and i get status 200 OK), there is no content-type header but i am unsure if that is an issue.
The MyLog final few lines contains the following:
[16/11/01@16:00:28.320+0000] P-001140 T-004340 1 4GL SOCKET READ: COMPLETE= yes
[16/11/01@16:00:28.320+0000] P-001140 T-004340 1 4GL SOCKET READ: ERROR= ?
[16/11/01@16:00:28.320+0000] P-001140 T-004340 1 4GL SOCKET READ: TOTAL TIME(ms)=252
[16/11/01@16:00:28.320+0000] P-001140 T-004340 1 4GL SOCKET READ: TOTAL SIZE(b)=445
I don't know the significance of READ:ERROR= ?, does this mean no error was encountered or that the error returned evaluated to ?
Please see attached.
Thanks for your help on this.
(edited to remove unique code from response).
Ok, that makes sense.
Thanks for your help!