Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TestSaleforce{
- public static void main(String[] args) throws UnexpectedErrorFault, ApiFault {
- // TODO Auto-generated method stub
- String username = "abc";
- String password = "abc";
- String authEndPoint = "https://tls1test.salesforce.com/services/Soap/u/35.0/";
- try {
- /* ConnectorConfig config = new ConnectorConfig();
- config.setUsername(username);
- config.setPassword(password);
- */
- System.out.println("AuthEndPoint: " + authEndPoint);
- //config.setAuthEndpoint(authEndPoint);
- SoapBindingStub binding = null;
- binding = (SoapBindingStub)new SforceServiceLocator().getSoap();
- binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, authEndPoint);
- LoginResult rs = null;
- rs = binding.login(username, password);
- // Print user and session info
- GetUserInfoResult userInfo = rs.getUserInfo();
- System.out.println("UserID: " + userInfo.getUserId());
- System.out.println("User Full Name: " + userInfo.getUserFullName());
- System.out.println("User Email: " + userInfo.getUserEmail());
- System.out.println(rs.getServerUrl() + rs.getSessionId());
- // System.out.println("SessionID: " + config.getSessionId());
- // System.out.println("Auth End Point: " + config.getAuthEndpoint());
- // System.out.println("Service End Point: " + config.getServiceEndpoint());
- binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, rs.getServerUrl());
- SessionHeader sh = new SessionHeader();
- sh.setSessionId(rs.getSessionId());
- binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(), "SessionHeader", sh);
- QueryOptions qo = new QueryOptions();
- System.out.println(new Date()+" SETTING Query Batch Size");
- qo.setBatchSize(new Integer(2000));
- binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(), "QueryOptions", qo);
- QueryResult qResult = null;
- String soqlQuery = "select RecordType.Name,Email,HasOptedOutOfEmail,Owner.Name,Owner.Email,BMS__leadOpp__r.Name,Id from lead WHERE (RecordType.Name='') AND IsConverted=FALSE";
- qResult = binding.query(soqlQuery);
- boolean done = false;
- if (qResult.getSize() > 0) {
- System.out.println("Logged-in user can see a total of " + qResult.getSize() + " contact records.");
- }
- } catch (RemoteException | ServiceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement