OnDemand Users Group

Support Forums => CMOD for Multiplatforms => Topic started by: Lars Bencze on November 04, 2015, 01:59:21 PM

Title: User Exit call to SOAP web service
Post by: Lars Bencze on November 04, 2015, 01:59:21 PM
Hi,

We need to do a lookup in one of the CMOD User Exits, arsuprep to be precise.
I have customized a User Exit before (arsusec), but that was not nearly as complex.

Has anyone had any experience writing User Exits, preferably in a Windows environment (Unix might do) like ours, and could you in that case tell us how we can call a Web Service via a SOAP call?
We are trying different "intermediate steps", such as a Java module or a DLL acting as the "middle man" here.

Any working examples would be appreciated, as well as pointing out caveats/bewares.

Thanks for reading!
Title: Re: User Exit call to SOAP web service
Post by: Alessandro Perucchi on November 04, 2015, 02:39:16 PM
Hello LarsB,

I've done such work with ARSUSEC and a webservice to check if the login was ok.

I've used the project Apache Axis2/C

http://axis.apache.org/axis2/c/core/ (http://axis.apache.org/axis2/c/core/)

it was something like:


#define _ARSUSEC_C

#include <stdio.h>
#include <stdio.h>
#include <axiom.h>
#include <axis2_util.h>
#include <axiom_soap.h>
#include "axis2c-client/axis2_stub_OnDemandSpecialService.h"

struct axis2_stub_sample {
        axis2_svc_client_t *svc_client;
        axis2_options_t *options;
} axis2_stub_sample_t;

static axutil_env_t *env;
static axis2_stub_t *stub;


ArcCSXitSecurityRC
ARSCSXIT_EXPORT
ARSCSXIT_API
SECURITY(
#ifdef CMOD9
                ArcChar *act_userid, ArcChar *cur_userid, ArcChar *cur_passwd, ArcChar *new_userid, ArcChar *new_passwd, ArcCSXitSecurityAction action, ArcChar *msg,
                ArcChar *clnt_id, ArcChar *instance, ArcChar *passthru_text, ArcU32 passthru_size, ArcByte *passthru_buf
#endif
#ifdef CMOD8
                char *act_userid, char *cur_userid, char *cur_passwd, char *new_userid, char *new_passwd, ArcCSXitSecurityAction action, char *msg, char *clnt_id,
                char *instance
#endif
) {
        ArcCSXitSecurityRC rc;
        msg[0] = '\0';

        if (action == ARCCSXIT_SECURITY_USER_LOGIN) {
                // ...
                 if (!stub) {
// Create stub
                printDebug("Setting up WS connection");
                if (!endpoint_uri) {
                        // setup_URL();
                        printDebug(endpoint_uri);
                }
                printDebug(client_home);
                env = axutil_env_create_all(axis_log_file, axis_log_level);
                stub = axis2_stub_create_OnDemandSpecialService(env, client_home, endpoint_uri);
             }
            if (stub) {
                // call the WS ...
            } else {
                printError("Problem with the connection to the WS, please check");
            }

                // ...
        } else {
                rc = ARCCSXIT_SECURITY_RC_OKAY;
        }
        return (rc);
}


I hope that helps a little bit how I've done it.
I will never use some JAVA as a middle man, because the java initialization is too slow... after that's ok, since it can be quite fast (near C implementation)... but for login, if possible I would like to avoid...

Hope that helps a little bit...

Alex
Title: Re: User Exit call to SOAP web service
Post by: Lars Bencze on November 04, 2015, 04:06:51 PM
Thank you Alex for your speedy reply, I will have a look at it!

Lars
Title: Re: User Exit call to SOAP web service
Post by: Lars Bencze on November 09, 2015, 06:44:11 AM
Hi Alex,

My programmer colleague reported that we almost immediately ran into problems. To being with, the axis software was no longer available for download - the ftp folder was empty. But after Googling a bit, we were able to find the downloads on a hidden web page. However, when we looked closer at the axis 2 modules, they were very old. Version 1.6.0 (windows binary) was dated 2009. That is not a problem per se, but the problem is that the code appears to be 32-bit, and it is also dependent on a whole array of other 32-bit modules (DLLs), which therefore (according to my colleague) cannot be compiled into a 64-bit DLL, which is what CMOD requires.
If you know of a way around the 32-bit problem, please advice.

I just read an email from my colleague that he has found another way to solve our problem. Apparently it works by using Microsoft's "winhttp" API. I will get back here later to tell about that solution.

Excerpt from the build file, with axis 2:
#############################################################################
### Dependant Binary Locations (Required) ###
#############################################################################
#
# libxml2 binary location ( axis2c is built with libxml2 )
LIBXML2_BIN_DIR = E:\libxml2-2.6.30.win32
#
# iconv binary location
ICONV_BIN_DIR = E:\iconv-1.9.2.win32
#
# zlib binary location
ZLIB_BIN_DIR= E:\zlib-1.2.3.win32
...
Title: Re: User Exit call to SOAP web service
Post by: Alessandro Perucchi on November 09, 2015, 09:03:42 AM
As I said, I am not a Windows specialist, so I cannot help you.
And maybe there are other solutions for windows than Axis/C... you might look at your .NET libraries... you might find something for C/C++.

Second, I NEVER use binaries when I have the source code, I prefer ALWAYS to recompile them, and like that I can compile them in 64bits if needed.

I have checked the AXIS project and it seems dead, so I had luck when I used the AXIS. Now I will need to find another C/C++ library for such WS services call  :'(
I found many for Java... but for C/C++ that's not that easy, especially if you want to stay on the open source, without using the GPL... maybe I should take the time and build one for my needs....