0
votes

I have a flow that is using the SalesForce connector to establish a connection and perform standard operations through the API. I have a new requirement for Mule to act as a web service proxy for an Apex class exposed as a service. Mule will need to insert or create a session Id before executing the Apex service. Since the other Mule flow will likely have a valid session Id, I did not want to create one needlessly. Is there anyway to retrieve the session Id that the SalesForce connector is creating and holding so that I can use it in my other flow?

Or is there a more simple way to call the Apex service which could make use of the SalesForce connector?

1
The connector itself exposes the session ID ( github.com/mulesoft/salesforce-connector/blob/master/src/main/… ) so it should be possible to retrieve it, maybe by retrieving it from the registry via MEL?David Dossot
Hi David, thanks. I was looking at their code as well and found that they have methods to check and return it. Do you know how to get the contents of the registry to see if they've already stored it? I couldn't find any code indicating they were putting it as a value on the registry. I wrote a class to attempt to get the ID and add it to the registry but if they are already doing so I'd rather just retrieve it.Mike M
Soemthing like #[app.registry.YourConnectorConfigName.sessionId] should/may work?David Dossot
Thanks David, there is a sessionId defined there but its the sessionId specified in the connector configuration. When adding MEL Watch on app.registry.Salesforce I can drill down into the connectionPool and eventually find the session used by the connection manager, but my MEL expression does not work correctly. The path is a mixture of attributes and elements, once I get into connectionPool it stops resolving in the MEL watch. app.registry.Salesforce.connectionPool._poolMap.0.value.queue.0.value.loginResult.sessionIdMike M
I just found that in the 4.0 version of the Salesforce connector schema, there was a operation for get-session-id. I have no idea why they would remove it from the 5.0 version.Mike M

1 Answers

0
votes

So for this project I was trying to build a web-service-proxy pattern to front a Apex Web Service, manage the login to Salesforce, and pass the Soap payload with the session Id to the Salesforce endpoint.

I ended up building a transformer that extended the AbstractMessageTransformer, and another class that extended Mule's SalesforceConnector module. The transformer used its existing instance of the SalesforceConnector or created a new one which created/got the sessionId and server Url from the LoginResult. The transformer then manipulates the XML to set the sessionId and return the message.

I couldn't find a way to get the Connector's pool, but this method only makes one login call as long as the session is active and will reconnect if it is not.