First of all we need an account with salesforce.com. With this account we can access the Web Services API through Profile -> Setup -> API. Here we need to download the Enterprise WSDL
You can find more details to this here salesforce.com Documentation.
Now we import the WSDL into the Oracle Service Bus. As written in the docs
Before invoking any other calls, a client application must first invoke the login() call to establish a session with the login server, set the returned server URL as the target server for subsequent API requests, and set the returned session ID in the SOAP header to provide server authorization for subsequent API requests.This means for Oracle Service Bus that we have to use an additional "Service Callout" before calling any other operation. With this in mind, it might be a good idea to store the session information for subsequent calls. As the Oracle Service Bus is stateless, this job could be achieved by using a java callout with a class variable storing the SF session ID.
package client;
public class LoginStore {
private static String sessionID = null;
private static String serverURI = null;
public LoginStore() {
super();
}
public LoginStore(String sessionID ,String serverURI) {
super();
this.sessionID = sessionID;
this.serverURI = sessionID;
}
public static void setSessionID(String sessionID) {
LoginStore.sessionID = sessionID;
}
public static String getSessionID() {
return sessionID;
}
public static void setServerURI(String serverURI) {
LoginStore.serverURI = serverURI;
}
public static String getServerURI() {
return serverURI;
}
}
I am also storing the Server URI for the subsequent calls.
Lets have a look into a Proxy Service to Update data on salesforce.com.
The two Java callouts read the values from the "LoginStore"into OSB variables.
The LoginPS first checks if we already have a sessionID, or if it is necessary to first login and then store the results.
The assign action contains the login data in the following form
<urn:login>
<urn:username>steffen.miller@oracle.com</urn:username>
<urn:password>SecretPassword8jlSMFQ41MjeNmIv84BZEkfpO</urn:password>
</urn:login>
The password consists of two parts, the password itself, here "SecretPassword" and a security token which was defined by salesforce.com and is found in the mail after user creation, or could be regenerated by changing the password, or invalidating the security token "Reset My Security Token". Than a new token is send by mail.
Now putting it all together, I need a Business Service offering the Operations available through the Enterprise Web service enterprise.wsdl, doing the connection work to salesforce.com. This Business Service is called in the above
CallSF_PS in the "route 2 salesforce.com" routing node.
<urn:SessionHeader>
<urn:sessionId>{ $sessionID }</urn:sessionId>
</urn:SessionHeader>
And the Routing Options action changes the Server URI to the dynamic URI returned from the login process.
Finally, the service can be tested with test console.
The complete OSB project can be downloaded here