Consider that we have a server which when triggered with a URL (with data within the URL), the Server responds by creating a PDF file.
In PowerBuilder tool, we trigger the URL via PostURL():
int ll_return
inet_base = CREATE inet
ll_return = inet_base.postURL('http://server:8080/postRender?', Blob, header string, port#, internetData)
In the postURL argument, the Blob is the data that was appended to the URL. The data is converted to blob and then passed as an argument.
The details of the postURL function is in below link: http://infocenter-archive.sybase.com/help/index.jsp?topic=/com.sybase.dc37781_1150/html/psref/CCJCIIFD.htm
Consider that the server returns 404 code with some message like: File not found!
I need help to write the PowerBuilder code to capture the response of the server. Currently, since we are using PostURL function to trigger POST request, in return I am getting only integers such as:
1 Success
-1 General error
-2 Invalid URL
-4 Cannot connect to the Internet
-5 Unsupported secure (HTTPS) connection attempted
-6 Internet request failed
After digging more into this issue, I find out that it is possible to capture the response message coming from the server.
Taking the reference of the above code:
int ll_return
inet_base = CREATE inet
ll_return = inet_base.postURL('http://server:8080/postRender?', Blob, header string, port#, internetData)
The last argument in the PostURL function is an object called InternetData. The InternetData is a object which contains a function named as internetdata(blob data).
The response message from the server is captured in the variable blob data. We need to convert the data to String as follows:
is_data = String(data, EncodingANSI!)
The variable is_data
will contain the HTML script which consists of the response message from the server.
Method to create an internetResult type of user object: