You need to sign in to do that
Don't have an account?
Jeyapriya J
Need to create SOAP request for Salesforce Integration
Hi,
I am new to Salesforce, we are working to create a SOAP message to get user information and eventually update the user record from Java application.
I searched for sample piece of code, the code with query option in developer site doesnt return me any information.
Could anyone guide me in creating a session and getting user information with SOAP API.
Regards
Jeyapriya J
I am new to Salesforce, we are working to create a SOAP message to get user information and eventually update the user record from Java application.
I searched for sample piece of code, the code with query option in developer site doesnt return me any information.
Could anyone guide me in creating a session and getting user information with SOAP API.
Regards
Jeyapriya J
From Setup, enter API in the Quick Find box, then select API to display the WSDL download page.
Download the appropriate WSDL:
If you’re downloading an enterprise WSDL and you have managed packages installed in your org, click Generate Enterprise WSDL. Salesforce prompts you to select the version of each installed package to include in the generated WSDL.
Otherwise, right-click the link for the appropriate WSDL document to save it to a local directory. In the menu, Internet Explorer users can choose Save Target As, while Mozilla Firefox users can choose Save Link As.
Step 2 : Generate the JAR file from WSDL
use the wsdlc utility to do it
Donwload the Jar file Step 3 :Calls login() to log in to the single login server
Step 4 : Create or update user bu using User Class from the jar file
Thank you for your reply. I have done till step 3 and I am able to establish a connection.
I need help with step 4.
From sObject I am not able to pull user information, do you have any sample of pulling user information from the connection established.
In our envrionment I am working with PartnerConnection.
Regards
Jeyapriya J
The SObject is not giving me any records.
SObject[] records = qr.getRecords();
getUserInfo() gives me the information of the ID through which I have established the connection but this is not my goal.
I am trying to get user information based on ID or alias, tired retrieve() call as well.
SObject[] sObjects = connection.retrieve("ID, Name, Website","Account", ids);
From SObject I am unable to retrieve the user data.
Account retrievedAccount = (Account) sObjects[i]; --> And also I am unable to cast SObject to account, could you let me know under which element I could find account.
Reference link - https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_retrieve.htm
If you have any sample could you please help me with that.
Regards
Jeyapriya J
Please find the code,
import com.sforce.soap.partner.Connector;
import com.sforce.soap.partner.DeleteResult;
import com.sforce.soap.partner.DescribeSObjectResult;
import com.sforce.soap.partner.PartnerConnection;
import com.sforce.soap.partner.QueryResult;
import com.sforce.soap.partner.SaveResult;
import com.sforce.soap.partner.Error;
import com.sforce.soap.partner.Field;
import com.sforce.soap.partner.FieldType;
import com.sforce.soap.partner.sobject.SObject;
import com.sforce.ws.ConnectionException;
import com.sforce.ws.ConnectorConfig;
import com.sforce.ws.transport.SoapConnection;
import sailpoint.connector.salesforce.webservices.partner.PicklistEntry;
public class sfConnection {
static final String USERNAME = "testID";
static final String PASSWORD = "testPassword";
static PartnerConnection connection;
public static void main(String[] args) {
ConnectorConfig config = new ConnectorConfig();
config.setUsername(USERNAME);
config.setPassword(PASSWORD);
//config.setTraceMessage(true);
try {
connection = Connector.newConnection(config);
System.out.println("connection get user info "+connection.getUserInfo());
// ArrayList idList = new ArrayList();
// String[] idArray = new String[1];
// idArray[0] = "0054C0000012nXh";
String[] idArray = {"0000C0000000000QAI","0000C0000000000QBI"};
SObject[] sObjects = connection.retrieve("ID, Name, Website","Account", idArray);
if (sObjects != null) {
for (int i = 0; i < sObjects.length; i++) {
/*
Account retrievedAccount = (Account) sObjects[i];
if (retrievedAccount != null) {
System.out.println("Account ID: " + retrievedAccount.getId());
System.out.println("Account Name: " + retrievedAccount.getName());
System.out.println("Account Website: " + retrievedAccount.getWebsite());
}
*/
}
}
}
catch (ConnectionException e1) {
e1.printStackTrace();
}
}
}
Regards
Jeyapriya J
It doesnt give me any Name information, I only get this C**?????? ????? ??? ???????????? ?????&\??6010b!
I need to get the contact or retrieveAccount, so I can pull other information from the user record.
I also need to pull data for permission set and group information.
Could you please provide some guidance.
Regards
Jeyapiry aJ
I believe I am missing some import for contact and retrievedAccount, the necessary import doesnt show up in my eclipse.
I have the partner.jar, force-wsc-43.0.0.jar, antlr-runtime-35.2.jar, js-1.7R2.jar,rhino-1.7.7.jar, ST4-4.0.08.jar.
Am I missing something or should I import any other jar, please confirm.
Regards
Jeyapriya J
I am unable to generate Enterprise WSDL currently and I guess there is some access issue, will try it out and confirm you.
Would importing enterprise.jar fix this issue. please confirm.
Regards
Jeyapriya J
Hopefully it works.
Imported the enterprise.jar but still the methods are showing error, is there any specific import you have in place that you could suggest.
Any help on this, would be helpful.
Regards
Jeyapriya J
Could you please give a bit more information on this comment... "import enterprise.jar from your org "
I downloaded the jar available in internet and it doesn't resolve the following.
import com.sforce.soap.enterprise.sobject.Revenue_Schedule2__c;
Does that mean I have to login to salesforce accoutn and donwload the enterprise jar specific for my company?
Thanks,
Shankar