Changing dynamically soap endpoint without using site properties

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?

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.

 

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

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.

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.


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

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.


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?

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

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.

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.

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