Question

My company runs a 4GL application internally. It's very old and no one really knows how to improve/develop for it since the developers are long gone.

I need to make a simple SOAP call to my Magento web store. There are tons of examples online in a multitude of languages, but I can't find a single 4GL (OpenEdege ABL) example.

I'm trying to set SKU's to Out of stock status.

Does anyone have a simple example that I can look at, or at least a starting point since there seems to be so little information on 4GL on the web.

Example of the call I need in PHP:

<?php
$proxy = new SoapClient('http://www.domain.com/api/soap/?wsdl');
$sessionId = $proxy->login('admin', 'password');

$proxy->call($sessionId, 'product_stock.update', array('sku123', array('qty'=>50, 'is_in_stock'=>1)));
Was it helpful?

Solution

For version 10.2B there's built in support for consuming web services in Progress ABL.

This is a basic tutorial of how to create a client for a SOAP-based web service in ABL. It's not best practices or in any way complete. Just a quick guide to get started.

1. Analyse the WSDL

There's a built in tool available via command line that lets you analyse a WSDL and create documentation about available services, datatypes, syntax etc. Invoke it on your wsdl like this:

proenv> bprowsdldoc yourwsdl-file c:\temp\docs

The wsdl can be local or remote. If its remote you specify the URL, if it's local you can specify just the local complete path. Documentation in html format will end up in c:\temp\docs. Open up index.html in that folder.

2. Create a basic client

In the index.html document there's a number of headings. Click the link under "Port types". In the Port Type document you will find some useful data.

Copy-and-paste the example in "Connection Details" into your Progress Editor. It should look something like this (names of services and procedures will be different - they are defined in the wsdl):

DEFINE VARIABLE hWebService AS HANDLE NO-UNDO.
DEFINE VARIABLE hYYY AS HANDLE NO-UNDO.

CREATE SERVER hWebService.

hWebService:CONNECT("-WSDL 'file_or_url_to_wsdl.wsdl'").

RUN XXX SET hYYY ON hWebService.

If you run this code your client is connected to the web service but it's still not doing anything.

Further down the same document there's a heading called "Operation (internal procedure) details". This is where the actual web service is invoked. It will look something like the code below. It actually show two ways of making the same call, one functional call and one procedural so choose whatever you prefer and insert it into your editor (I'm usually using the procedural for no real reason other than old habits):

DEFINE VARIABLE strXMLRequest AS CHARACTER NO-UNDO.
DEFINE VARIABLE ProcessXMLResult AS CHARACTER NO-UNDO.


FUNCTION ProcessXML RETURNS CHARACTER
  (INPUT strXMLRequest AS CHARACTER)
  IN hYYY.


/* Function invocation of ProcessXML operation. */
ProcessXMLResult = ProcessXML(strXMLRequest).


/* Procedure invocation of ProcessXML operation. */
RUN ProcessXML IN hYYY (INPUT strXMLRequest, OUTPUT ProcessXMLResult).

Now all you need to end your program is disconnecting and cleaning up. So insert:

hWebService:DISCONNECT().
DELETE OBJECT hWebService.

If you've followed all steps you should have a skeleton for invoking a web service. The only problem is that you need to handle the in- and out-data.

3. Handle the answer and the request

Depending on how the web service is built this can be easy (if you only input and output simple data like strings and numbers) or quite complicated (if you input and output entire xml-documents). The documentation you created in step one lists all datatypes (in the index.html document) but it doesn't offer any support in how you create any needed xml documents. There's specific Progress documentation available on how to work with xml...

The better approach is to take a look at the official documentation. There you will find everything above and more - how to handle errors etc.

Here is an overview of all 10.2B documentation and here is the PDF named Web Services.

Here is a link to a complete (but actually not so good) example in the Progress KnowledgeBase where a client and corresponding request/response xml is created and handled.

Look at these chapters:

  • 6 - Creating an ABL Client from WSDL
  • 7 - Connecting to Web Services from ABL
  • 8 - Invoking Web Service Operations from ABL

That will basically take you through the entire process from start to beginning.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top