Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Java Development
- :
- How to write trigger webservices java?
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
How to write trigger webservice s java?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
10-05-2012 12:13 AM
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.InvalidQueryLocat
import com.sforce.soap.enterprise.fault.InvalidSObjectFau
import com.sforce.soap.enterprise.fault.LoginFault;
import com.sforce.soap.enterprise.fault.MalformedQueryFau
import com.sforce.soap.enterprise.fault.UnexpectedErrorFa
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_ADDR
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) {
}
}
}

