63
Views
16
Comments
Changing dynamically soap endpoint without using site properties
Question

I want to be able to, at runtime, change the endpoint of a soap api to be able to get information from diferente databases but with the same method names. I can do this with site properties but since the module will be reused by several applications the site propertie would be the same for all applications and i dont want that.

Any help finding a solution?

Rank: #14436

Hi Nordin

I use this already in the onBeforeRequestAdvanced of the soap but in the scope of the scope it only accepts site properties but, like i said this site propertie would be share in all applications using this integration module. Is there a way to use something other than site properties or someway to pass a value too the onBeforeRequestAdvanced.

 

mvp_badge
MVP
Rank: #73

Hi Flávio,

If you would want to pass a value to the OnBeforeRequestAdvanced action, while not using a Site Property, AFAIK you're only option would be to use a Session Variable instead. You can access its value within the scope of the OnBeforeRequest action.

Regards,

Nordin

Rank: #14436

Nordin Ahdi wrote:

Hi Flávio,

If you would want to pass a value to the OnBeforeRequestAdvanced action, while not using a Site Property, AFAIK you're only option would be to use a Session Variable instead. You can access its value within the scope of the OnBeforeRequest action.

Regards,

Nordin

Sorry i forgot to mention that this is for mobile applications so i dont have session variables, i tried with client variables but they are not available in the scope of the onBeforeRequest action.


Hi Flavio,

Good morning!

I'm thinking of how about you wrap in a server action the extraction/returning the value of the appropriate site property for the URi for the specific app as part of the OnBeforeRequest logic..

Hope this helps,

Kind regards,

Chris

Champion
Rank: #105

Or create a single entry entity where you fetch the URI from.
Then have a backoffice screen where you can change it (so it's somewhat like a site property)

I would advise against using a session variable, if you try to run it from a process or timer it will not have the desired value.

mvp_badge
MVP
Rank: #73

In that case, you should go with Joey's proposal. 

You can save the URI to an Entity and fetch the record via an Aggregate and pass the value to the ChangeEndpoint action.

Regards,

Nordin

Rank: #14436

Nordin Ahdi wrote:

In that case, you should go with Joey's proposal. 

You can save the URI to an Entity and fetch the record via an Aggregate and pass the value to the ChangeEndpoint action.

Regards,

Nordin

In this case it will be almost the same because the entity would be shared by every application so there would be several records for each uri so how can i filter this agregate to feach the uri that i want if theres several records?

Since i cant add a input variable to the OnBeforeRequest.


mvp_badge
MVP
Rank: #73

Flávio Monteiro wrote:

Nordin Ahdi wrote:

In that case, you should go with Joey's proposal. 

You can save the URI to an Entity and fetch the record via an Aggregate and pass the value to the ChangeEndpoint action.

Regards,

Nordin

In this case it will be almost the same because the entity would be shared by every application so there would be several records for each uri so how can i filter this agregate to feach the uri that i want if theres several records?

Since i cant add a input variable to the OnBeforeRequest.


I see what you’re saying.
I’m just spit balling here, but what if you update that record with the URI you want to use before calling the SOAP API?

Of course I don’t have the entire context, so I’m not sure if this is possible in your situation.

Regards,

Nordin


Hi All

Isn't this what the action SetWebReferenceURL in the EnhancedWebReferences extension is for?

It only works for SOAP APIs, but that's what you're using, right?

Rank: #14436

Yes, but can i use this action before calling the soap action i need in another action besides the onBeforeRequest?

Rank: #14436

When i put the name of the soap in using in the input of the action SetWebReferenceURL i get this error.


Oh, I see.

OutSystems broke stuff that worked fine in older versions and is telling *you* to fix it.

That's nice.

Anyway, seems to be you need to wrap the calls to the SOAP API in an action, and one of the parameters for this wrapper has to be a caller identifier, so you can then fetch the endpoint from the database.

To be fair, using wrappers is a good idea anyway, because instead of having multiple espaces consuming the API, you'll only have one, which makes maintenance a lot easier.

Rank: #14436

Sorry could you elaborate a bit more? what is a caller identifier and are u sugesting for me to save the soap endpointst in the database? Is there any way i can do this dynamically change to the endpoint of the soap?

I even tried to call a soap action using a javascript node but it didnt seam to work.

Oh wait, I missread your post about using an entity to store the endpoints.

Well, I have bad news for you.

So, technically you can change site properties on runtime, it's just that doing it is usually a bad idea because it'll automatically do a TenantInvalidateCache which will kill the performance of your application.

Well, if you're only calling that SOAP API once a day in a timer, then it's not that bad, but if you're calling it in response to an action by the user then you really shouldn't do this.

The other only option I see would be to use an extension to call the SOAP API...


Edit to add: or it used to, these days it might only do an EspaceInvalidadeCache, which, while still being bad, is not as bad as the TenantInvalidateCache.

Rank: #34054

Hi All,

I am facing now the same issue when I consume a SOAP service with Outsystems 11 in the case I describe below:

I have 30 different fiscal companies, each of them with a software (ERP) exposing a SOAP service with the same WSDL (same structure/methods).

When I consume one of this services using deprecated SetWebReference (EnhancedWebReferences extension) action, it is perfect! Allows me to consume only 1 SOAP service instead of 30 SOAP services and communicate with each of them just changing the end point URI at run time with current scope of my wrapper action:


Now, after Outsystems upgrade to achieve SOAP v1.2, i can't implement same logic with callback action OnBeforeRequest. Why? Because i can't pass values to OnBeforeRequest as input variables, and, inside of it, we only have access to session variables or site properties, and using them, in my opinion, it is not a good idea...

In my opinion, it is not a good idea use:

  • Session variables - asynchronous tasks (timers and processes) have no session
  • Site Properties - EspaceInvalidadeCache 
  • Database Entity to save URI at wrapper action and get it after at OnBeforeRequest - it is bad because i don't kown if i am processing right URI, and it is also not a good solution to lock(Get <Entity> ForUpdate) the entity and make "sequential requests" ... it doesn't make sense


Does anyone already have a solution to this problem?


Thanks!!