You need to sign in to do that
Don't have an account?
How to write trigger in a webservices java program
Hi All,
I am working on salesforce to java through integration, I am new to webservices and triggers.
plz see the below webservices program and how to trigger the web services.
plz help..
package com.ws;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.xml.rpc.ServiceException;
import com.sforce.soap.enterprise.LoginResult;
import com.sforce.soap.enterprise.QueryResult;
import com.sforce.soap.enterprise.SessionHeader;
import com.sforce.soap.enterprise.SforceServiceLocator;
import com.sforce.soap.enterprise.SoapBindingStub;
import com.sforce.soap.enterprise.fault.InvalidFieldFault;
import com.sforce.soap.enterprise.fault.InvalidIdFault;
import com.sforce.soap.enterprise.fault.InvalidQueryLocatorFault;
import com.sforce.soap.enterprise.fault.InvalidSObjectFault;
import com.sforce.soap.enterprise.fault.LoginFault;
import com.sforce.soap.enterprise.fault.MalformedQueryFault;
import com.sforce.soap.enterprise.fault.UnexpectedErrorFault;
import com.sforce.soap.enterprise.sobject.Contact;
public class ContactBpartner {
private static final String USERNAME = "";
private static final String TOKEN = "";
private static final String PASSWORD = "" + TOKEN;
private SoapBindingStub binding;
public static void main(String args[]) throws InvalidSObjectFault, MalformedQueryFault, InvalidFieldFault, InvalidIdFault, UnexpectedErrorFault, InvalidQueryLocatorFault, RemoteException, InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
ContactBpartner d = new ContactBpartner();
d.login();
d.search();
}
private void login() throws InvalidIdFault, UnexpectedErrorFault, LoginFault, RemoteException {
try {
binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
} catch (ServiceException e1) {
e1.printStackTrace();
}
LoginResult loginresult = null;
loginresult = binding.login(USERNAME, PASSWORD);
binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY,
loginresult.getServerUrl());
SessionHeader sh = new SessionHeader();
sh.setSessionId(loginresult.getSessionId());
binding.setHeader(new SforceServiceLocator().getServiceName()
.getNamespaceURI(), "SessionHeader", sh);
}
private void search() throws InvalidSObjectFault, MalformedQueryFault,
InvalidFieldFault, InvalidIdFault, UnexpectedErrorFault,
InvalidQueryLocatorFault, RemoteException, InstantiationException,
IllegalAccessException, ClassNotFoundException, SQLException {
Connection conn = null;
PreparedStatement ps = null;
StringBuffer sql = new StringBuffer(256);
try{
QueryResult qr = binding.query("select id, Name from Contact ");
if (qr.getSize() > 0) {
for (int i = 0; i <= qr.getSize(); i++) {
Contact l = (Contact)qr.getRecords(i);
..........................................................
...................................................................................................
..................................................................................
}
}
}catch (Exception e) {
}
}
}