Consuming external webservice SOAP

SOLVED

Hello guys, 

Someone can tell me please if it's possible to invoke an external webservice (soap) using 4GL ? 

I don't find any information here about this subject. 

Thanks

Parents Reply
  • 0 in reply to Esfahani

    Hello,
    I saw the post that you mention, but there only says that we need to use javabridge in soap cases . I have now a pdf with some examples but it's only with get method and I can't understand the example because the links are outdated. Did you have any example how to use with post method or tutrial for this ?
    I appreciate your time,
    Thanks so much

Children
  • 0 in reply to Cristina Rodrigues

    To use soap in java bridge you do it the same way you handle it in java (with some limitations of OSGI libraries available (like most of the stubs I've seen were not generated by 4GL call), it is a bit complicated to alter OSGI configuration in java bridge setup).

    Below is my experience (v7, tested on v11):

    1. You should have workspace for Eclipse provided with Java Bridge server - install it, it will allow you to build/test OSGI bundles.

    2. There is small documentation pdf (ENG - Safe X3 Java Bridge SDK Client.pdf) with Java bridge which is barely helpful, but it shows how to make a simple bundle, install and call it from 4GL. 

    3. Next - stub generation from wsdl - I use wsimport tool. You will have a class to work with your SOAP service.

    4. Now, we have OSGI project, java class for SOAP. Code your java file, generate bundle - upload. 

    PS. If you wish to use manual XML generation:

    1. That is what Sage documentation said (sage bundle, did not work for me, I needed SSL support, and it was not there until recent update, so I use method 2 for calls):

    package com.sage.x3.bridge.sdk.httpclient;

    /**
    * Use POST method
    *
    * @param aUrlString
    * The requested URL
    * @param aData
    * The data
    * @return An Http Response
    * @throws Exception
    */
    public X3HttpResponse post(String aUrlString, String aData)
    throws Exception {
    return pServiceHttpClient.post(pHttpClientId, aUrlString, aData);
    }

    2. Standard httpclient, from org.apache.http.client (the library is pre-installed):

    	HttpClient client = HttpClientBuilder.create().build();
    	HttpPost post = new HttpPost(url);

    and follow apache documentation.

  • 0 in reply to Cristina Rodrigues

    Hi,

    if you are familiar with javascript, then developping a js bundle may be the fastest way to approach this.

    We have done it successfully and doesn't require any extra setup. You may start by searching "javascript" in documentation. Although I'm not sure from which version is the js bundle available.

  • 0 in reply to Cristina Rodrigues

    Hello, 

    One my colleagues reminded me that you may not need to use java bridge to send external SOAP request, and you could use our EXEC_HTTP calls directly from 4GL. 

    See this example. 

    https://github.com/Delamater/X3/blob/master/4GL/ZEXEC_HTTP


    Regards,