function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Micky MMicky M 

Web Service

Hi all,

Could anyone help me, i need to call a salesforce web method from java, ive got the code to connect to salesfroce and ive genterated the jars from my wsdl's using wsc. So im at the point where i can connect and run soql statements against salesforce and get results back and process them. But i need to be able to call a web method directly rather than run soql. Does anyone have any code to do this?


You can use the "Retrieve()" call to get a single record using the record's ID, instead of the Query() call:

Another way is to write your own APEX web service methods in salesforce:

Micky MMicky M
Hi yeah thanks thats pretty much what ive already done. Ive got code at the moment like this :

QueryResult queryResult = connection.query("Select id, FirstName, LastName, Account.Name from Contact WHERE AccountId != null");

but ive written some web methods in apex and i want to call those methods from java.
You should generate Apex WSDL for those classes you've written and create jars from the WSDL:
Micky MMicky M
Yeah ive already done that, im after the code that says here's how you call the method really.
This should help then:
Micky MMicky M
ah thanks! thats almost it athough i get this:

com.sforce.soap.DataWarehouseContractIvoicesWebservice.GetContractIvoice_element do you know what the _element bit is rather then com.sforce.soap.DataWarehouseContractIvoicesWebservice.GetContractIvoice ?

Micky MMicky M
sorry that was me being dumb, ok the code i have now looks like this :

   com.sforce.soap.DataWarehouseContractIvoicesWebservice.SoapConnection soap = new com.sforce.soap.DataWarehouseContractIvoicesWebservice.SoapConnection(config);
   System.out.println("Session header in query invoice = " + config.getSessionId());
   MCS_Contract_Recurring_Service_Invoice__c results = soap.getInvoiceDetails("a2CM0000000GGyhMAG");
  catch (ConnectionException ex) {
   Logger.getLogger(SalesforceMethods.class.getName()).log(Level.SEVERE, null, ex);

but im getting this error? No operation available for request {}getInvoiceDetails

any ideas?