Consuming a web service

maretix

Member
Hi to all.
I have not a good experience in consuming web services.
I have a quite good basis in 4GL.
I use Progress 10.2.b version in Unix Environment.

Reading some articles in www.progress.com and in this useful site, i was able to create a custom demo.p that consume a web service.
In this program , I invoke a web service that everyone can find and use for test on web. http://www.webservicex.net/stockquote.asmx?WSDL

Now i need to 'consume' a web service written in PHP Language of an external software house.
Is this below the only manner to invoke a web service in Progress ???
In WSDL file there are parts of it that refers to :

Stock Quote Soap (I used it as port type name in demo.p listed below)
Stock Quote Http Get (when and how to use that port ???)
Stock Quote Http Post (when and how to use that port ???)
If I used Http Get and Post port , how do i need to modify my demo.p program ???

Surely i am doing little bit confusion...please forgive me !!!

I post my demo.p ..program

DEF VAR Parametro1 AS CHAR INIT 'GE'.


DEF VAR Parametro2 ASCHAR FORMAT 'X(500)' INIT''.


DEF VAR LccResult AS LONGCHAR.
DEFINE VARIABLE hWebService AS HANDLE.
DEFINE VARIABLE hPortType AS HANDLE.

DEF TEMP-TABLE Stock
FIELD Symbol AS CHAR

FIELD Name AS CHAR
INDEX i1 Symbol.

CREATE SERVER hWebService.


/*-----------------------*/
/* WSDL Schema Location */

/*-----------------------*/

hWebService:CONNECT("-WSDL 'http://www.webservicex.net/stockquote.asmx?WSDL ' ") NO-ERROR.

IF NOT hWebService:CONNECTED() THEN

DO:

DEFINE VARIABLE errmsg AS CHARACTER NO-UNDO INIT "SERVER NOT CONNECTED~n".
DEFINE VARIABLE i AS INTEGER NO-UNDO.

DO i = 1 TO ERROR-STATUS:NUM-MESSAGES:
errmsg = errmsg + ERROR-STATUS:GET-MESSAGE(i) + '~n'.
END.
MESSAGE errmsg VIEW-AS ALERT-BOX ERROR.
STOP.

END.

/*-----------------------------------------------------------------------------------*/
/*Es. RUN <portTypeName> SET hPortType ON SERVER hWebService.*/
/*------------------------------------------------------------------------------------*/
RUN StockQuoteSoap SET hPortType ONSERVER hWebService.

/*------------------------------*/
/* Invocazione del Metodo */
/*------------------------------*/
RUN GetQuote IN hPortType (INPUT Parametro1, OUTPUT Parametro2) NO-ERROR.

IF ERROR-STATUS:ERROR THEN
MESSAGE'Error: ' + ERROR-STATUS:GET-MESSAGE(1) VIEW-AS ALERT-BOX.
ELSE
MESSAGE'Result: ' + TRIM(parametro2)/***return-value***/VIEW-AS ALERT-BOX.

ASSIGN LccResult = Parametro2.

.......other instructions to read result with READ-XML method and import data in a tt-table...
 

RealHeavyDude

Well-Known Member
Calling a web service you should not need to know anything about the technology it is implemented in because it should not matter to you. If it does the creator of the web service violated the standard. Therefore, from the ABL perspective it does not matter.

Did you try the bprowsdldoc that will generate the code stubs for you?
http://knowledgebase.progress.com/articles/Article/P172455

Code:
bprowsdldoc "http://www.webservicex.net/stockquote.asmx?WSDL[/URL]"

Heavy Regards, RealHeavyDude.
 

TomBascom

Curmudgeon
"Web services" mean different things to different people. The most formal variety is SOAP, which uses WSDL, Progress provides direct support for SOAP which simplifies the programming quite a lot.

GET and POST are methods used in REST services. These are much less formal in nature. To code REST services in 4GL (especially oe10 or earlier) you need to write your own socket code. (There is some new REST stuff in recent OE11 versions but you are not using those releases.)

The command line "curl" utility can often be used to work with REST services.
 

TheMadDBA

Active Member
What Tom said....

I am a big fan of using curl instead of trying to re-invent the wheel in older versions of OE/Progress (and even the newest versions).

curl supports various versions of SSL, proxies and adding in the headers that some services require. Simple to use... easy to debug.
 

maretix

Member
Calling a web service you should not need to know anything about the technology it is implemented in because it should not matter to you. If it does the creator of the web service violated the standard. Therefore, from the ABL perspective it does not matter.

Did you try the bprowsdldoc that will generate the code stubs for you?
http://knowledgebase.progress.com/articles/Article/P172455

Code:
bprowsdldoc "http://www.webservicex.net/stockquote.asmx?WSDL[/URL]"

Heavy Regards, RealHeavyDude.

Good Evening.
Thanks for your kind reply.
I read about it...i will try to understand better ...
This website is very useful...
I will try to write real web services against real request...
Thanks again..
 

maretix

Member
"Web services" mean different things to different people. The most formal variety is SOAP, which uses WSDL, Progress provides direct support for SOAP which simplifies the programming quite a lot.

GET and POST are methods used in REST services. These are much less formal in nature. To code REST services in 4GL (especially oe10 or earlier) you need to write your own socket code. (There is some new REST stuff in recent OE11 versions but you are not using those releases.)

The command line "curl" utility can often be used to work with REST services.
Good evening.
Thanks for your kind reply.
I think i will use WSDL ...
I did not know anything about REST services..
I will try to study about them...
My first example is using WSDL...
Now begin difficult part...try to consume real thirdy party web services..
Will see..
Thanks again.
 

maretix

Member
Good evening.
Thanks for your useful advice.
I will try to study about REST services...even if i think i will have to use web services with WSDL.
Thanks again.
 
Top