• gh
  • NEWBIE
  • 0 Points
  • Member since 2004

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 7
    Replies

The documentation states the following:

"Client applications do not need to explicitly log out to end the session. Sessions expire automatically after a period of inactivity, which can be configured (in the Setup section in the salesforce.com user interface) for your organization to be 30, 60, or 120 minute intervals. If you have a client application that periodically polls the sforce Web service at an interval longer than the configured time-out, then that application should log in each time to obtain a new session. "

I'm trying to find where under Setup this is configured. Under Administration Setup/Security Controls/Session Settings I can change the "session timeout" up to 4 hours. Does this affect the sForce Session ID expiration or does this only apply to salesforce.com UI sessions? I'm confused because the setting values are 30 min, 1 hour, 2 hours and 4 hours and the documentation says "30, 60, or 120 minute intervals", which leads me to believe I'm in the wrong place and the sForce sessions are configured elsewhere. Please advise. Thanks.

  • May 11, 2004
  • Like
  • 0
I've noticed that "Email Opt Out" and "Do Not Call" fields for both Contacts and Leads is not available through the API. Am I missing something? I need to acccess these fields. Thanks.
  • May 02, 2004
  • Like
  • 0
I've noticed that "Email Opt Out" and "Do Not Call" fields for both Contacts and Leads is not available through the API. Am I missing something? I need to acccess these fields. Thanks.
  • May 02, 2004
  • Like
  • 0

In my servlet, login is working, but when I run a query I get the following:

AxisFault

 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException

 faultSubcode:

 faultString: java.io.IOException: No serializer found for class com.sforce.soap.enterprise._SessionHeader in registry org.apache.axis.encoding.TypeMappingImpl@13c550f

Here is the query code:

    QueryResult qr = null;

                //call the query saving the results in qr
                try {
                        qr = binding.query("select Name, numberOfEmployees, Id, Industry from Account");
                } catch (Exception e) {
                        e.printStackTrace();
                        return;
                }

                //always a good idea
                if (qr != null) {
                        records = qr.getRecords();

                        //we can loop through the returned records
                        for (int i=0;i<records.length;i++) {
                                //Because we asked for accounts we will convert
                                //the SObject for each record into an Account object
                                Account account = (Account)records[i];

                                //Now we can access any of the fields we had in the query
                                //select clause directly from the account variable
                                System.out.print(new Integer(i+1).toString() + ". ");
                                System.out.print(account.getName() + " - ");
                                System.out.println(account.getId().getValue());
                        }
                        System.out.println("");
                }

 

 

  • April 27, 2004
  • Like
  • 0

I'm in the process of trying to convert the Enterprise java example to a servlet. The login works fine, but when I try to execute a query I get the followingn error:

Failed to execute query succesfully, error message was:
; nested exception is:
 java.io.IOException: No serializer found for class com.sforce.soap.enterprise._SessionHeader in registry org.apache.axis.encoding.TypeMappingImpl@96ad7c

My guess is that I'm not persisting or passing the login session header to the query request. Can someone tell me how to do this in a servlet or JSP? I can't find examples of this anywhere. Here is my servlet:

package sforcetest3;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.io.BufferedReader;
//import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Vector;

import javax.xml.rpc.ServiceException;

import com.sforce.soap.enterprise.DescribeGlobalResult;
import com.sforce.soap.enterprise.DescribeSObjectResult;
import com.sforce.soap.enterprise.Field;
import com.sforce.soap.enterprise.FieldType;
import com.sforce.soap.enterprise.GetDeletedResult;
import com.sforce.soap.enterprise.GetUpdatedResult;
import com.sforce.soap.enterprise.GetUserInfoResult;
import com.sforce.soap.enterprise.ID;
import com.sforce.soap.enterprise.LoginResult;
import com.sforce.soap.enterprise.PicklistEntry;
import com.sforce.soap.enterprise.QueryResult;
import com.sforce.soap.enterprise.ResetPasswordResult;
import com.sforce.soap.enterprise.SaveResult;
import com.sforce.soap.enterprise.SearchRecord;
import com.sforce.soap.enterprise.SearchResult;
import com.sforce.soap.enterprise.SetPasswordResult;
import com.sforce.soap.enterprise.SforceServiceLocator;
import com.sforce.soap.enterprise.SoapBindingStub;
import com.sforce.soap.enterprise._QueryOptions;
import com.sforce.soap.enterprise._SessionHeader;
//import com.sforce.soap.enterprise.fault.LoginFault;
import com.sforce.soap.enterprise.sobject.Account;
import com.sforce.soap.enterprise.sobject.Contact;
import com.sforce.soap.enterprise.sobject.Lead;
import com.sforce.soap.enterprise.sobject.SObject;
import com.sforce.soap.enterprise.sobject.Task;
import com.sforce.soap.enterprise.sobject.User;
import com.sforce.soap.enterprise.fault.*;

public class Servlet1
    extends HttpServlet {
  private static final String CONTENT_TYPE = "text/html";
  private SoapBindingStub binding;
  private LoginResult loginResult = null;
  private String un = "XXX";
  private String pw = "XXX";
  private boolean loggedIn = false;
  private GetUserInfoResult userInfo = null;
  private ID[] accounts = null;
  private ID[] contacts = null;
  private ID[] tasks = null;

  //Initialize global variables
  public void init() throws ServletException {
  }

  //Process the HTTP Get request
  public void doGet(HttpServletRequest request, HttpServletResponse response) throws
      ServletException, IOException {

    response.setContentType(CONTENT_TYPE);
    PrintWriter out = response.getWriter();

    if (request.getQueryString() == null) { // login if

      out.println("attribute names: " + request.getQueryString());

      out.println("Creating the binding to the web service...<P>");

      /*
       * There are 2 ways to get the binding, one by passing a url to
       * the getSoap() method of the SforceServiceLocator,
       * the other by not passing a url.  In the second case the binding
       * will use the url contained in the wsdl file when the proxy was
       * generated.
       */
      try {
        binding = (SoapBindingStub)new SforceServiceLocator().getSoap();
      }
      catch (ServiceException ex) {
        out.println(
            "ERROR: createing binding to soap service, error was: \n"
            + ex.getMessage());
        out.print("Hit return to continue...<P>");
      }

      // Time out after a minute
      binding.setTimeout(60000);

      //Attempt the login giving the user feedback
      out.println("LOGGING IN NOW....<P>");
      try {
        loginResult = binding.login(un, pw);
      }
      catch (LoginFault lf) {
        out.println(lf.getExceptionMessage());
        //lf.printStackTrace();
      }
      catch (UnexpectedErrorFault uef) {
        out.println(uef.getExceptionMessage());
        uef.printStackTrace();
      }
      catch (RemoteException re) {
        out.println(re.getMessage());
        re.printStackTrace();
      }

      out.println("The session id is: " + loginResult.getSessionId() + "<P>");
      out.println("The new server url is: " + loginResult.getServerUrl() +
                  "<P>");

      //set the session header for subsequent call authentication
      try {
        binding = (SoapBindingStub)new SforceServiceLocator().getSoap(new URL(
            loginResult.getServerUrl()));
      }
      catch (ServiceException jre) {
        System.out.println(
            "ERROR: creating binding to soap service, error was: \n" +
            jre.getMessage());
      }
      catch (MalformedURLException e) {
        e.printStackTrace();
      }

      //Create a new session header object and set the session id to that returned by the login
      _SessionHeader sh = new _SessionHeader();
      sh.setSessionId(loginResult.getSessionId());
      binding.setHeader("SforceService", "SessionHeader", sh);

      out.println("<a href=/sForceWeb/servlet1?doQuery=1>query</a>");

    } // login if

    //out.println(request.getParameter("doQuery"));

    if (request.getParameter("doQuery") != null) {
      out.println("doQuery");

      QueryResult qr = null;
      _QueryOptions qo = new _QueryOptions();
      qo.setBatchSize(new Integer(3));
      binding.setHeader("SoapService", "QueryOptions", qo);

      try {
        qr = binding.query(
            "select id, Website, Name from Account where Name = 'Golden Straw'");
        if (qr.getSize() != 0) {
          Account account = ( (Account) qr.getRecords()[0]);
         out.println("Retrieved " + new Integer(qr.getSize()).toString() +
                             " account(s) using Name = 'Golden Straw', ID = "
                             + account.getId().getValue()
                             + ", website = "
                             + account.getWebsite());
        }

        qr = binding.query("select FirstName, LastName, Id from Contact");

        boolean bContinue = true;
        int loopCount = 0;
        while (bContinue) {
          out.println("Results set " + new Integer(loopCount++).toString() +
                             " - ");
          //process the query results
          for (int i = 0; i < qr.getRecords().length; i++) {
            Contact con = (Contact) qr.getRecords()[i];
            String fName = con.getFirstName();
            String lName = con.getLastName();
            if (fName == null) {
              out.println("Contact " + (i + 1) + ": " + lName);
            }
            else {
              out.println("Contact " + (i + 1) + ": " + fName + " " +
                                 lName);
            }
          }
          //handle the loop + 1 problem by checking to see if the most recent queryResult
          if (qr.isDone()) {
            bContinue = false;
          }
          else {
            qr = binding.queryMore(qr.getQueryLocator());
          }
        }
        out.println("\nQuery succesfully executed.");
        //getUserInput("\nHit return to continue...");
      }

      catch (UnexpectedErrorFault uef) {
        System.out.println(uef.getExceptionMessage());
      }
      catch (Exception ex) {
        System.out.println(
            "\nFailed to execute query succesfully, error message was: \n"
            + ex.getMessage());
      }

    }

  }

  //Process the HTTP Post request
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws
      ServletException, IOException {
    doGet(request, response);
  }

  //Clean up resources
  public void destroy() {
  }
}

 

  • April 27, 2004
  • Like
  • 0
Could someone point me to some JSP examples for the Enterprise wsdl? Thanks!
  • April 26, 2004
  • Like
  • 0

In the developer edition the Campaigns screen always shows the intro page. I can't figure out how to bypass this screen and see the actual Campaigns data. I can create a new Campaign from the sub-menu of the Home page but that's it. My "Marketing User" checkbox is on. If I click "Don't show me this page again" it takes me to the "Customize My Tabs" screen under set-up.

The Dashboard screen also shows an intro page, but I can click "Continue" to get to the actual Dashboards page.

Any ideas?

  • April 25, 2004
  • Like
  • 0

The documentation states the following:

"Client applications do not need to explicitly log out to end the session. Sessions expire automatically after a period of inactivity, which can be configured (in the Setup section in the salesforce.com user interface) for your organization to be 30, 60, or 120 minute intervals. If you have a client application that periodically polls the sforce Web service at an interval longer than the configured time-out, then that application should log in each time to obtain a new session. "

I'm trying to find where under Setup this is configured. Under Administration Setup/Security Controls/Session Settings I can change the "session timeout" up to 4 hours. Does this affect the sForce Session ID expiration or does this only apply to salesforce.com UI sessions? I'm confused because the setting values are 30 min, 1 hour, 2 hours and 4 hours and the documentation says "30, 60, or 120 minute intervals", which leads me to believe I'm in the wrong place and the sForce sessions are configured elsewhere. Please advise. Thanks.

  • May 11, 2004
  • Like
  • 0

Seems that the Campaigns Tab feature is not working for a new Developer Edition account.

I clickthrough the "Do Not Show This Page Again" link on the new campaign features page and I am taken to the Customize My Tabs page with no way to ultimately get to the Campaigns page.

 

In my servlet, login is working, but when I run a query I get the following:

AxisFault

 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException

 faultSubcode:

 faultString: java.io.IOException: No serializer found for class com.sforce.soap.enterprise._SessionHeader in registry org.apache.axis.encoding.TypeMappingImpl@13c550f

Here is the query code:

    QueryResult qr = null;

                //call the query saving the results in qr
                try {
                        qr = binding.query("select Name, numberOfEmployees, Id, Industry from Account");
                } catch (Exception e) {
                        e.printStackTrace();
                        return;
                }

                //always a good idea
                if (qr != null) {
                        records = qr.getRecords();

                        //we can loop through the returned records
                        for (int i=0;i<records.length;i++) {
                                //Because we asked for accounts we will convert
                                //the SObject for each record into an Account object
                                Account account = (Account)records[i];

                                //Now we can access any of the fields we had in the query
                                //select clause directly from the account variable
                                System.out.print(new Integer(i+1).toString() + ". ");
                                System.out.print(account.getName() + " - ");
                                System.out.println(account.getId().getValue());
                        }
                        System.out.println("");
                }

 

 

  • April 27, 2004
  • Like
  • 0

I'm in the process of trying to convert the Enterprise java example to a servlet. The login works fine, but when I try to execute a query I get the followingn error:

Failed to execute query succesfully, error message was:
; nested exception is:
 java.io.IOException: No serializer found for class com.sforce.soap.enterprise._SessionHeader in registry org.apache.axis.encoding.TypeMappingImpl@96ad7c

My guess is that I'm not persisting or passing the login session header to the query request. Can someone tell me how to do this in a servlet or JSP? I can't find examples of this anywhere. Here is my servlet:

package sforcetest3;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.io.BufferedReader;
//import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Vector;

import javax.xml.rpc.ServiceException;

import com.sforce.soap.enterprise.DescribeGlobalResult;
import com.sforce.soap.enterprise.DescribeSObjectResult;
import com.sforce.soap.enterprise.Field;
import com.sforce.soap.enterprise.FieldType;
import com.sforce.soap.enterprise.GetDeletedResult;
import com.sforce.soap.enterprise.GetUpdatedResult;
import com.sforce.soap.enterprise.GetUserInfoResult;
import com.sforce.soap.enterprise.ID;
import com.sforce.soap.enterprise.LoginResult;
import com.sforce.soap.enterprise.PicklistEntry;
import com.sforce.soap.enterprise.QueryResult;
import com.sforce.soap.enterprise.ResetPasswordResult;
import com.sforce.soap.enterprise.SaveResult;
import com.sforce.soap.enterprise.SearchRecord;
import com.sforce.soap.enterprise.SearchResult;
import com.sforce.soap.enterprise.SetPasswordResult;
import com.sforce.soap.enterprise.SforceServiceLocator;
import com.sforce.soap.enterprise.SoapBindingStub;
import com.sforce.soap.enterprise._QueryOptions;
import com.sforce.soap.enterprise._SessionHeader;
//import com.sforce.soap.enterprise.fault.LoginFault;
import com.sforce.soap.enterprise.sobject.Account;
import com.sforce.soap.enterprise.sobject.Contact;
import com.sforce.soap.enterprise.sobject.Lead;
import com.sforce.soap.enterprise.sobject.SObject;
import com.sforce.soap.enterprise.sobject.Task;
import com.sforce.soap.enterprise.sobject.User;
import com.sforce.soap.enterprise.fault.*;

public class Servlet1
    extends HttpServlet {
  private static final String CONTENT_TYPE = "text/html";
  private SoapBindingStub binding;
  private LoginResult loginResult = null;
  private String un = "XXX";
  private String pw = "XXX";
  private boolean loggedIn = false;
  private GetUserInfoResult userInfo = null;
  private ID[] accounts = null;
  private ID[] contacts = null;
  private ID[] tasks = null;

  //Initialize global variables
  public void init() throws ServletException {
  }

  //Process the HTTP Get request
  public void doGet(HttpServletRequest request, HttpServletResponse response) throws
      ServletException, IOException {

    response.setContentType(CONTENT_TYPE);
    PrintWriter out = response.getWriter();

    if (request.getQueryString() == null) { // login if

      out.println("attribute names: " + request.getQueryString());

      out.println("Creating the binding to the web service...<P>");

      /*
       * There are 2 ways to get the binding, one by passing a url to
       * the getSoap() method of the SforceServiceLocator,
       * the other by not passing a url.  In the second case the binding
       * will use the url contained in the wsdl file when the proxy was
       * generated.
       */
      try {
        binding = (SoapBindingStub)new SforceServiceLocator().getSoap();
      }
      catch (ServiceException ex) {
        out.println(
            "ERROR: createing binding to soap service, error was: \n"
            + ex.getMessage());
        out.print("Hit return to continue...<P>");
      }

      // Time out after a minute
      binding.setTimeout(60000);

      //Attempt the login giving the user feedback
      out.println("LOGGING IN NOW....<P>");
      try {
        loginResult = binding.login(un, pw);
      }
      catch (LoginFault lf) {
        out.println(lf.getExceptionMessage());
        //lf.printStackTrace();
      }
      catch (UnexpectedErrorFault uef) {
        out.println(uef.getExceptionMessage());
        uef.printStackTrace();
      }
      catch (RemoteException re) {
        out.println(re.getMessage());
        re.printStackTrace();
      }

      out.println("The session id is: " + loginResult.getSessionId() + "<P>");
      out.println("The new server url is: " + loginResult.getServerUrl() +
                  "<P>");

      //set the session header for subsequent call authentication
      try {
        binding = (SoapBindingStub)new SforceServiceLocator().getSoap(new URL(
            loginResult.getServerUrl()));
      }
      catch (ServiceException jre) {
        System.out.println(
            "ERROR: creating binding to soap service, error was: \n" +
            jre.getMessage());
      }
      catch (MalformedURLException e) {
        e.printStackTrace();
      }

      //Create a new session header object and set the session id to that returned by the login
      _SessionHeader sh = new _SessionHeader();
      sh.setSessionId(loginResult.getSessionId());
      binding.setHeader("SforceService", "SessionHeader", sh);

      out.println("<a href=/sForceWeb/servlet1?doQuery=1>query</a>");

    } // login if

    //out.println(request.getParameter("doQuery"));

    if (request.getParameter("doQuery") != null) {
      out.println("doQuery");

      QueryResult qr = null;
      _QueryOptions qo = new _QueryOptions();
      qo.setBatchSize(new Integer(3));
      binding.setHeader("SoapService", "QueryOptions", qo);

      try {
        qr = binding.query(
            "select id, Website, Name from Account where Name = 'Golden Straw'");
        if (qr.getSize() != 0) {
          Account account = ( (Account) qr.getRecords()[0]);
         out.println("Retrieved " + new Integer(qr.getSize()).toString() +
                             " account(s) using Name = 'Golden Straw', ID = "
                             + account.getId().getValue()
                             + ", website = "
                             + account.getWebsite());
        }

        qr = binding.query("select FirstName, LastName, Id from Contact");

        boolean bContinue = true;
        int loopCount = 0;
        while (bContinue) {
          out.println("Results set " + new Integer(loopCount++).toString() +
                             " - ");
          //process the query results
          for (int i = 0; i < qr.getRecords().length; i++) {
            Contact con = (Contact) qr.getRecords()[i];
            String fName = con.getFirstName();
            String lName = con.getLastName();
            if (fName == null) {
              out.println("Contact " + (i + 1) + ": " + lName);
            }
            else {
              out.println("Contact " + (i + 1) + ": " + fName + " " +
                                 lName);
            }
          }
          //handle the loop + 1 problem by checking to see if the most recent queryResult
          if (qr.isDone()) {
            bContinue = false;
          }
          else {
            qr = binding.queryMore(qr.getQueryLocator());
          }
        }
        out.println("\nQuery succesfully executed.");
        //getUserInput("\nHit return to continue...");
      }

      catch (UnexpectedErrorFault uef) {
        System.out.println(uef.getExceptionMessage());
      }
      catch (Exception ex) {
        System.out.println(
            "\nFailed to execute query succesfully, error message was: \n"
            + ex.getMessage());
      }

    }

  }

  //Process the HTTP Post request
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws
      ServletException, IOException {
    doGet(request, response);
  }

  //Clean up resources
  public void destroy() {
  }
}

 

  • April 27, 2004
  • Like
  • 0

In the developer edition the Campaigns screen always shows the intro page. I can't figure out how to bypass this screen and see the actual Campaigns data. I can create a new Campaign from the sub-menu of the Home page but that's it. My "Marketing User" checkbox is on. If I click "Don't show me this page again" it takes me to the "Customize My Tabs" screen under set-up.

The Dashboard screen also shows an intro page, but I can click "Continue" to get to the actual Dashboards page.

Any ideas?

  • April 25, 2004
  • Like
  • 0

 

Does anyone know how id's are given out for a custom entity Salesforce?

I presumed that the last 15 characters (case sensitive) followed a sequence "0-9" then "A-Z" and then "abcdefghijklmnopqrstuvwxyz". It seems to be sequential for a while and then jumps forward.

e.g. 000A, 000B, 000C, 000D and then 021C

The reason for this is that I am developing an sControl to generate a sequential number such as an order number.

I do this by inserting a record into a custom enitity which returns a unique id each time, I then convert it to a number using the following function:

calculate(salesforceId.substring(4,15))

function convert(input) {
var convertBase="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var  origin;
var  dest;
var origin=61;
var dest=10;
var b=0;
var Result="";
if (Number(origin)>convertBase.length || Number(dest)>convertBase.length || Number(origin)<2 || Number(dest)<2) return "Invalid numbering system"
for (var c=1;c<=input.length;c++) { b+=convertBase.indexOf(input.substring(c-1,c))*(Math.pow(origin,input.length-c)); if
(convertBase.indexOf(input.substring(c-1,c)) > Number(origin)) return 'Character "'+input.substring(c-1,c)+'" not present in origin system'; }
var a=Math.floor(Math.log(b)/Math.log(dest))
while (a>-1) {
  var e=Math.pow(dest,a)
  a--;
  var d=(b-b%e)/e+1;
  b%=e;
  Ciffer=convertBase.substring(d-1,d);
  Result+=Ciffer;
  }
return Result
}

The problem is that every so often the sequence breaks.

 

  • February 19, 2004
  • Like
  • 0