Call SOAP web service within another in Sage X3

SUGGESTED

Hello,

I created a SOAP web service that calls a subprog on which I apply some logic and then call an object-based SOAP web service, like this:

Subprog CONSUMED_BY_EXTERNAL_APPLICATION(SOME_PARAMETERS)
    #apply some logic, verifications, etc
    FOO = 1
    
    #Call another subprog that calls the object-based web service
    Call CALL_OBJ_WS(OTHER_PARAMETERS)
End

Subprog CALL_OBJ_WS(PARAM)
    #Define variables
    Local Char    TEXTE(20)
    Local Integer I , J , K
    Gosub DEFVAR From WJWSMYWS
    
    #Define parameters
    MY_PARAMS = PARAM
    
    #Set action: creation
    WW_ACTION   = "CREATE"      : # READ, CREATE, MODIFY, DELETE, SUPLIG, INSLIG
    WW_IDENT    = ""            : # Clé de l Objet Val1~Val2
  
    Onerrgo ERR_WS
    Gosub WEBSERV     From WJWSMYWS
    Gosub ANALRESOBJ  From WJWSMYWS
    Onerrgo
End

Everything works fine if there is no problem on the object-based web service, the trouble starts with error handilng: status and messages are passed to the subprog WS (against my will) so the response to the outer program will be a fail, but I don't want to, what I want is to perform custom error handling by myself. This makes no sense to me: the response to the web service call should be related to the subprog web service, not to the object-based one.

I guess this may be due to variables that have the same name, but they all have local scope so they should be kept private when I call the inner subprog, so I don't understand.

Any ideas?

Thanks in advance

  • 0
    SUGGESTED

    Hi,

    I suggest posting this question in the Development forum, they would be better suited to provide coding assistance and can advise on possible issues with your error handling coding.

    Thanks 

  • 0 in reply to NevilleC

    Hi,

    thank you for your suggestion. Do you mean https://developer.sage.com/x3? I think that's a read-only website, I don't see a community or Q&A section over there.

    Thanks

  • 0 in reply to tc43

    There should be a "Community" link at the top of the page.

    Or try this "https://developer-community.sage.com/"

    Let me know if you don't have access and I'll inquire about the process to join.

    Thanks 

  • 0 in reply to NevilleC

    I don't know how I missed that! Thank you, I'll post it there.

  • 0

    HI
    Sorry but I don't understand what you're doing based on your example. Your example is a wrapper program based on an object. Please post your wrapper example that doesn't work for a published subprogram.

  • 0 in reply to Bruno Gonzalez

    Dear ,

    I didn't post the real code I'm using because it's on a custom object, so it would be meaningless outside of my organization. Anyway, let's take as an example the GESAUS function (Users), and let's say:

    • I added some code on it so that it refuses creation if the user code is shorter than 5 characters (from GUI as well)
    • I created and published a SOAP web service for that object (AUS)
    • I created a wrapper program that accepts some input from outside, does some processing and retrieves the data to send to the SOAP web service above
    • I created and published a SOAP web service for the subprogram above

    Something like this:

    Subprog CONSUMED_BY_EXTERNAL_APPLICATION(PARAM_0, PARAM_1, PARAM_2, PARAM_3)
        Value Char PARAM_0, PARAM_1, PARAM_2, PARAM_3
        
        #apply some logic, verifications, etc. Get a name for the customer
        NEW_USER_NAME   = func MYFUNCTION(PARAM_0, PARAM_1)
        NEW_USER_DESCR  = func MYFUNCTION(PARAM_2)
        EMAIL_ADDR      = func MYFUNCTION(PARAM_3)
        
        #Call another subprog that calls the object-based web service
        Local Char SOME_PARAMETER_CALCULATED_DURING_USER_CREATION(50)
        
        #Simple custom validation (example)
        Local Tinyint SUCCESS
        Call CALL_OBJ_WS(NEW_USER_NAME, NEW_USER_DESCR, EMAIL_ADDR, SOME_PARAMETER_CALCULATED_DURING_USER_CREATION)
        If SOME_PARAMETER_CALCULATED_DURING_USER_CREATION = ""
            SUCCESS = 0
        Else
            SUCCESS = 1
        Endif
    End
    
    Subprog CALL_OBJ_WS(NEW_USER_NAME, NEW_USER_DESCR, EMAIL_ADDR, SOME_PARAMETER_CALCULATED_DURING_USER_CREATION)
        Variable Char SOME_PARAMETER_CALCULATED_DURING_USER_CREATION
        Value Char NEW_USER_NAME, NEW_USER_DESCR, EMAIL_ADDR
        
        #Define variables for web service
        Local Char    TEXTE(20)
        Local Integer I , J , K
        Gosub DEFVAR From WJWSAUS
        
        #Define parameters
        USR_A       = NEW_USER_NAME
        LOGIN_B     = NEW_USER_NAME
        INTUSR_A    = NEW_USER_DESCR
        ADDEML_B    = EMAIL_ADDR
        # Actually, you need much more data to call this web service, I omit it
        # to simplify the example, but an easy method to get it right would be
        # to read a model user with the webservice first and then change only
        # what needs to be changed.
        
        #Set action: creation
        WW_ACTION   = "CREATE"      : # READ, CREATE, MODIFY, DELETE, SUPLIG, INSLIG
        WW_IDENT    = ""            : # Clé de l Objet Val1~Val2
      
        Onerrgo ERR_WS
        Gosub WEBSERV     From WJWSAUS
        Gosub ANALRESOBJ  From WJWSAUS
        Onerrgo
        
        SOME_PARAMETER_CALCULATED_DURING_USER_CREATION = YPARAM_B
    End

    So my external application calls the subprog-web service and the first program above is executed; as you can see, that subprogram is trying to call another web service (object-based) to create a new user.

    Let's say that the user creation fails because the given username is 4 characters long, so shorter than 5: the object-web service exits logging an error (somewhere...), and I want the subprog-web service to finish its execution without errors, just reporting SUCCESS==0 to the external app that does the SOAP call. Sadly, it ends with an error that I'm failing to reproduce right now due to some modifications on code (but I'll update the post in a frew days).