• David Lee 8
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies
I am developing a web service for a particular client that can only consume namespace http://developer.intuit.com/
How can I set a custom NameSpace in Apex class?
I am trying to generate and parse JSON, but JSONGenerator and JSONParser do not seem to work. Execution stops without any errors.

for example, run the following code in the console:
 
List<Contact> contacts = [SELECT Id, Name FROM Contact LIMIT 10]; 
System.debug(1);
JSONGenerator generator = JSON.createGenerator(true);
System.debug(2);
generator.writeStartObject();
generator.writeNumberField('count', contacts.size())
generator.writeEndObject();
String jsonString = generator.getAsString();
System.debug(jsonString);
All I get is USER_DEBUG [14]|DEBUG|1. There are no errors in the output. Same happens when I try to use JSONParser.
 
Hello Folks,
I suddenly have an issue connecting to the Partner API as any attempt to reconnect results in a INVALID_SESSION_ID.
The sandbox has no issues making the connection and the production environment had no issues as well until today when the logs started indicating no new sessions were being establised. It showed the following error message:

"INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session. Session not found, missing session key: XXX"

No changes were made to the password nor the token.
The partner api connection url in sandbox is: https://cs16.salesforce.com/services/Soap/u/31.0

As shown below in the Java excerpt below, any unsuccessful attempts in connecting to the Partner API should result in creating a new session but is faliing to do so.
try {
			// Check if session is still valid
			connection.getServerTimestamp();
			return true;
		}
		catch (UnexpectedErrorFault uef) {
			if (uef.getExceptionCode() == ExceptionCode.INVALID_SESSION_ID) {
				logger.info("Session was invalid. Attempting to start new session");
				try {
					this.connection = new PartnerConnection(this.getConfig());
					return true;
				}
				catch (ApiFault af) {
					logger.error("Salesforce ApiFault Exception occurred");
					logger.error(af.getExceptionCode().toString());
					logger.error(af.getExceptionMessage());
					return false;
				}
        }

Could any one suggest or advise what could have possibly gone wrong?

Thanks in advance for your help!
Regards,
I have a Java application that's connecting to Salesforce using PartnerConnection.
Queries work fine at first but overnight it seems like the session expires/becomes invalid. What's the best way to check if the session is valid without performing a query?
connection.getServerTimestamp();
doesn't seem to work. Once I catch the error, would creating a new PartnerConnection work?:
catch (UnexpectedErrorFault uef) {
    if (uef.getExceptionCode() == ExceptionCode.INVALID_SESSION_ID) {
        this.connection = new PartnerConnection(this.getConfig());
Thanks.
I am trying to generate and parse JSON, but JSONGenerator and JSONParser do not seem to work. Execution stops without any errors.

for example, run the following code in the console:
 
List<Contact> contacts = [SELECT Id, Name FROM Contact LIMIT 10]; 
System.debug(1);
JSONGenerator generator = JSON.createGenerator(true);
System.debug(2);
generator.writeStartObject();
generator.writeNumberField('count', contacts.size())
generator.writeEndObject();
String jsonString = generator.getAsString();
System.debug(jsonString);
All I get is USER_DEBUG [14]|DEBUG|1. There are no errors in the output. Same happens when I try to use JSONParser.
 
Hello Folks,
I suddenly have an issue connecting to the Partner API as any attempt to reconnect results in a INVALID_SESSION_ID.
The sandbox has no issues making the connection and the production environment had no issues as well until today when the logs started indicating no new sessions were being establised. It showed the following error message:

"INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session. Session not found, missing session key: XXX"

No changes were made to the password nor the token.
The partner api connection url in sandbox is: https://cs16.salesforce.com/services/Soap/u/31.0

As shown below in the Java excerpt below, any unsuccessful attempts in connecting to the Partner API should result in creating a new session but is faliing to do so.
try {
			// Check if session is still valid
			connection.getServerTimestamp();
			return true;
		}
		catch (UnexpectedErrorFault uef) {
			if (uef.getExceptionCode() == ExceptionCode.INVALID_SESSION_ID) {
				logger.info("Session was invalid. Attempting to start new session");
				try {
					this.connection = new PartnerConnection(this.getConfig());
					return true;
				}
				catch (ApiFault af) {
					logger.error("Salesforce ApiFault Exception occurred");
					logger.error(af.getExceptionCode().toString());
					logger.error(af.getExceptionMessage());
					return false;
				}
        }

Could any one suggest or advise what could have possibly gone wrong?

Thanks in advance for your help!
Regards,