• Losintikfos
  • NEWBIE
  • 125 Points
  • Member since 2008

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 31
    Questions
  • 140
    Replies

Hi,

For instance I create a new Account and I need to update its list of Contacts. What if the best way?

Is the line below correct? Thank you

 

anAccount.getContacts().getValue().getRecords().add(aContact);

Hi Guys,

 

Do anyone know why this statement is not working?

 

 

SELECT Id, Name FROM Account WHERE Id IN (SELECT FirstName, LastName FROM Contact where AccountId ='00120000008rnQJAAY')

 

Cheers.

 

Can anyone guide me through how to SOQL JOIN statement from Apex?

I am trying to something like this;
Code:

SELECT Name, ServiceProduct__c FROM Service__c JOIN PricebookEntry
ON Service__c.ServiceProduct__c = PricebookEntry.product2Id

 Do anyone know how to achieve this using enterprise API and Apex SOQL?




This case is closed! requirement changed.


Sorry Guys.


Message Edited by Losintikfos on 10-17-2008 03:45 AM
Hi Experts,


I am doing something like this;

Code:
Date start = sd.Start_Date__c;

and then pass start to external service like this;

stub.createServ(start);

Unfurtunately i am getting exception:

Debug Log:

System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: NumberFormatException date string can not be less than 19 charactors faultcode=soapenv:Server faultactor=


I am pretty sure i need to do something to the raw value of date before passing it to the remote method.
Do anyone know what to do?

Remote Java Exception
NumberFormatException For input string: "2008-08-01"


Message Edited by Losintikfos on 10-15-2008 03:45 AM
Hi Experts,

I have this method that i am trying to use trigger to invoke byt keeps getting;
Save error: Method does not exist or incorrect signature: ServiceAccount.createServ(LIST:SOBJECT:Service__c)

Below is the method i am using to invoke my external webservice.
Code:
global class ServiceAccount{
   @future 
     static void createServ(){
  Service__c sd = new Service__c();
  
     Boolean rental = sd.Rental__c;
     String alias = sd.Billing_Alias__c;
     String freq  = sd.Frequency__c;
  
            wsServiceAccount.ServiceAccountHttpSoap11Endpoint stub = new wsServiceAccount.ServiceAccountHttpSoap11Endpoint();
                   String call = stub.CreateService(rental, alias, freq);  
                   //return call;
        }
   }

This is the trigger:
Code:
trigger ServiceAccount on Service__c (before insert, before update) {
 ServiceAccount.createServ(trigger.new);
}
I have tried passing Array Primitive to the method and tried several options but won't work. Do anyone know what to do? experts advice please.

My requirement is to use the trigger to automatically invoke the apex class for remote process before insert.



Need your help experts!:smileysad:
 

 

Hi Experts,


Do anyone know how to define methods that are defined as asynchronous,
that is, defined with the @future keyword? Simple sample will be highly appreciated.


B
I am using a JavaScript to pass BillingStreet field to an appex script and keeps poping up with the error below;

A problem with the OnClick JavaScript for this button or link was encountered:
unterminated string literal.

When i pass in AccountAlias it works.

Do anyone knws whats' happening? do i need to do do some validity checks on the billing field?



pls. Hlp.


Message Edited by Losintikfos on 10-03-2008 03:18 AM
Hi Experts,

It Looks like i am battle with some interface implentation issue here!
I am getting the error:

Area java.lang.ClassCastException: com.sforce.soap.enterprise.sobject.impl.SObjectImpl cannot be cast to com.sforce.soap.enterprise.sobject.Account

From doing the following;
Code:
Account obj = (Account)sObjects[j];

Closely look at the trace reveals that, the Account and SObject interface and implementation classes in the packages;
com.sforce.soap.enterprise.sobject and
com.sforce.soap.enterprise.sobject.impl
Are not doing the job when deployed to the webservice server and hence the ClassCastException.

Do anyone know if this is a bug or something missing in my application!


Pls. Hlp.:smileysad:


Hi Experts,

Do anyone knows why i am getting ClassCastException from below code?

Code:
sObjects[] = queryResult.getRecordsArray();
 for (int j = 0; j < sObjects.length; j++) {
     Account obj = (Account) sObjects[j];
           String id = obj.getId();
    }

com.sforce.soap.enterprise.sobject.impl.SObjectImpl cannot be cast to com.sforce.soap.enterprise.sobject.Account



Message Edited by Losintikfos on 10-01-2008 05:59 AM
Hi Experts,

I have this trigger;
Code:
trigger addParent on Account (before insert, before update) {
 addParent.addAddress(trigger.new);
}

 I also have this apex class which is invoked by the trigger;
 
Code:
public class addParent{

 public static void addAddress(Account[] acc)
   {
    /**Set Set variables to hold the result as class members**/
    String parent;
    String pCode;
  
        parent = acc[0].ParentId;
           
         for (Account ac : [select Billing PostalCode where Id = :parent]) {
               pCode = ac.BillingPostalCode;
              }
              acc[0].BillingPostalCode = pCode;
          }
     }

 I am using this test coverage below;
 
Code:
public class testAddParentAddress {
    
    public static testMethod void testAddParent(){
    List<Account> accl = new Account[]{new Account()};
    accl[0] = new Account(Name = 'test', ParentId = '001R000000955CDIAY', BillingState = 'MASS', BillingCity = 'Tazmania',    BillingCountry = 'AUS', BillingPostalCode = 'MJ 25355', BillingStreet ='St. Kilda');
  
    String  pCode = accl[0].BillingPostalCode;
 String Street= accl[0].BillingStreet;
 
 System.assertEquals('MJ 25355', pCode);
 System.assertEquals('St. Kilda', Street);
 
    addParent.addAddress(accl);
      
     for (Account o : [select BillingState, BillingCity, BillingCountry, BillingPostalCode, BillingStreet from Account where Name = 'Test'])
     {
      o.BillingState= 'UK' ;
      update o;
     }
    }

}

 Unfurtunately i get error;
 Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required

  Can anyone help to resolve this?





hi Experts,

Do anyone knows how to write a test method for the code below?

Code:
public class addParent{

 public static void addAddress(Account[] acc)
   {
    /**Set Set variables to hold the result as class members**/
    String parent;
    String pCode;
  
            parent = acc[0].ParentId;
           
         for (Account ac : [select Billing PostalCode where Id = :parent]) {
               pCode = ac.BillingPostalCode;
              }
              acc[0].BillingPostalCode = pCode;
          }
     }

 Really need your help :smileywink: with some psuedo to kick this running!
    
Hi Experts,

I am using an appex class with a method definition like this;
Code:
public class addParent{
   public static void addAddress(Account acc){ 
   /**Method function here**/
}
}

I am trying to use below trigger to fire up the apex class;

Code:
trigger addAddressTrigger on Account
                            (before insert) {
  addParent.addAddress(Trigger.new);
}

 Ufurtunatly i am getting Error:
Compile Error: Method does not exist or incorrect signature: addParent.addAddress(LIST:SOBJECT:Account)


Do anyone knows what i am doing wrong here?


Message Edited by Losintikfos on 09-22-2008 02:39 AM
Hi Experts,


Do anyone know how to construct SOQL statement in Apex?
Hi Experts,

I am using an appex class and a trigger(before create) to update the address field of the account with its' parent address.
I am using below code, but keeps getting error:
Error: Compile Error: expecting a semi-colon, found '' at line 6 column 31

Can someone tell me what i am doing wrong in here?

public class addParent{

 public static void addAddress(Account[] a){
  // Account a:acc;
     String parent = a.ParentId;    
                    apex.query(select Id, BillingState, BillingCity, BillingCountry, BillingPostalCode, from Account where Id = 'parent');
                    function(qry:QueryResult):void {
                        if (qry.size > 0){
                            a.BillingState = qry.BillingState;
                            a.BillingCit = qry.BillingCity;
                            a.BillingPostalCode = qry.BillingPostalCode;
                            a.BillingCountry = qry.BillingCountry;
                        }
                    }
            }
     }
Hi Experts,

Quick advice! i have a WSDL2Apex class on my sandbox which i want to deploy to prod. My question is, do i need to write a test class for it before it can be successfully loaded to salesforce?



B
Hi Experts!


Do anyone knows how to create Apex Class on production?

I have tried to create apex Class directly from production but donot have the button to do create new. So i decided to use my IDE but after saving to server the code donot appear.


Any advice on why this is happening?


B
hi experts,

Do anyone know how i can ultilize call back inside below code to return success from my web services: I am getting error Remote server did not return any
content: System.CallbackException



global class APiNorthstar {

WebService static boolean addAccount(string AccA, String name){

comNorthstarApi.NorthstarServiceHttpSoap11Endpoint stub = new
comNorthstarApi.NorthstarServiceHttpSoap11Endpoint();

String createAcc = stub.createAcc(name, AccA);

return true;
}
}

JAVASCRIPT

{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")} 
{!REQUIRESCRIPT("/soap/ajax/10.0/functions")} 
sforce.debug.trace = true; 
try 
{ 
var con = confirm("Are you sure you want to create Northstar account for this Client?") 
if (con) 
var name = "{!Account.Account_Alias__c}"; 
var AccA = "{!Account.Name}"; 
var action = sforce.apex.execute("APiNorthstar","addAccount", {AccA: AccA, name: name}); 
alert(action); 
} 
catch (ex) 
{ 
alert ("Failed : " + ex); 
}



Message Edited by Losintikfos on 08-04-2008 05:55 AM
Hi Experts,

I am using a button which is using a javascript to invoke an apex class. Basically i want to update my external database using the Apex class. But if click on the button i get an exception: args not specified.

JavaScript
=========
try{
var con = confirm("Are you sure you want to create Northstar account for this user?")
if (con)
var action = sforce.apex.execute("APiNorthstar","addAccount");
}
catch (exception)
{
alert ("Failed : " + exception);
}

Apex Class
=========
public class APiNorthstar {

public static void addAccount(){

//Get new Account
Account accs = new Account();

comNorthstarApi.NorthstarServiceHttpSoap11Endpoint stub = new
comNorthstarApi.NorthstarServiceHttpSoap11Endpoint();
String Id = accs.Id;
String name = accs.name;
String acc = accs.Account_Alias__c;
Boolean setName = stub.setNa(name);
Boolean setAccountAlias = stub.setAcca(acc);
}
}

Do anyone know why this? please help!



Message Edited by Losintikfos on 07-31-2008 07:09 AM
This forum doesn't seem to have active members helping at all  - been new to salesforce, i find it extremely difficult. Guys do you want to share your experiences with with the dummies! plus i think salesforce dev team should do something about this.
Hi Experts,



I am trying to develop a system which uses s-control or apex to access my internal RDBMS and display data on the salesforce web portal. Do anyone know how to hit the ground running with this one? I have already deployed a javaBean as a WSDL service or WService and want to know how to interface this with to access data from salesforce portal.

Any sample code or kick start advice will be very essential.


B:smileyhappy:

Hi

 

       Is there any way to generate XML file with the QueryResult object?

       

Thanks,

--bdr

Message Edited by bdr_09 on 01-27-2010 02:11 AM
  • January 27, 2010
  • Like
  • 0

I have a trigger which executes after an update.  Is there a way to tell a difference between an API update or a update from the Case page in the trigger?

 

Cheers,

Timothy

I downloaded the enterprise.wsdl and using axis tools managed to get the wsdl2java tool working and built the java stubs for the wsdl.  I'm trying to do a simple login into SalesForce and grab some data from the contact object, an extremely simple app.  I cannot find the SoapBindingStub and I am completely stuck and its making me so mad.  Below is a list of the java classes that were created as a result of using axis tools.

 

InvalidFieldFault.java

InvalidIdFault.java

InvalidNewPasswordFault.java

InvalidQueryLocatorFault.java

InvalidSObjectFault.java

LoginFault.java

MalformedQueryFault.java

MalformedSearchFault.java

SforceServiceCallbackHandler.java

SforceServiceStub.java

UnexpectedErrorFault.java

 

I read somewhere that SoapBindingStuf is found is SforceServiceStub.java but I cannot find it anywhere.  I am really stuck here and any help that anybody could give, I would really appreciate it.  I am kinda new to java as I'm mainly a .NET guy and this is bothering me.

 

Ralph

 

Hi,

in my sandbox environment someone has created (the administrator?) a new profile called "External who".

 

We can't read (edit/delete/clone) the profile details.

Do you know where it comes from?

Thanks

F.

Hi,

 

I have a simple WSDL file which I need to parse in SFDC. When I am trying to do a 'generate from wsdl' I am getting below error.

 

Error: Failed to parse wsdl: Found more than one wsdl:binding. WSDL with multiple binding not supported

 

WSDL:-

 

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://ws.apache.org/axis2" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://ws.apache.org/axis2">
    <wsdl:documentation>
        Please Type your service description here
    </wsdl:documentation>
    <wsdl:types>
        <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://ws.apache.org/axis2">
            <xs:element name="summation">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="a" type="xs:int"/>
                        <xs:element minOccurs="0" name="b" type="xs:int"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="summationResponse">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="return" type="xs:int"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:schema>
    </wsdl:types>
    <wsdl:message name="summationRequest">
        <wsdl:part name="parameters" element="ns:summation"/>
    </wsdl:message>
    <wsdl:message name="summationResponse">
        <wsdl:part name="parameters" element="ns:summationResponse"/>
    </wsdl:message>
    <wsdl:portType name="FirePortType">
        <wsdl:operation name="summation">
            <wsdl:input message="ns:summationRequest" wsaw:Action="urn:summation"/>
            <wsdl:output message="ns:summationResponse" wsaw:Action="urn:summationResponse"/>
        </wsdl:operation>
    </wsdl:portType>
 
    <wsdl:binding name="FireSoap12Binding" type="ns:FirePortType">
        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
        <wsdl:operation name="summation">
            <soap12:operation soapAction="urn:summation" style="document"/>
            <wsdl:input>
                <soap12:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap12:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:binding name="FireHttpBinding" type="ns:FirePortType">
        <http:binding verb="POST"/>
        <wsdl:operation name="summation">
            <http:operation location="Fire/summation"/>
            <wsdl:input>
                <mime:content type="text/xml" part="summation"/>
            </wsdl:input>
            <wsdl:output>
                <mime:content type="text/xml" part="summation"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="Fire">
        <wsdl:port name="FireHttpSoap11Endpoint" binding="ns:FireSoap11Binding">
            <soap:address location="http://10.227.75.47:8080/Webservice_provider/services/Fire.FireHttpSoap11Endpoint/"/>
        </wsdl:port>
        <wsdl:port name="FireHttpSoap12Endpoint" binding="ns:FireSoap12Binding">
            <soap12:address location="http://10.227.75.47:8080/Webservice_provider/services/Fire.FireHttpSoap12Endpoint/"/>
        </wsdl:port>
        <wsdl:port name="FireHttpEndpoint" binding="ns:FireHttpBinding">
            <http:address location="http://10.227.75.47:8080/Webservice_provider/services/Fire.FireHttpEndpoint/"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

 

 

I tried to remove the second binding tag as found in the error but still the error persists. Any idea would be of

great help

 

 

Thanks

indranily81

 

I'm trying to connect the salesforce API by creating a web service client in java (Axis).

 

I'm behind proxy and I have set the property that is required for connecting a web service for proxy

The code that I'm using is 

 

            binding = (SoapBindingStub) new SforceServiceLocator().getSoap();

            binding._setProperty("http.proxySet", "true");
            binding._setProperty("http.proxyHost", <proxy-host>);
            binding._setProperty("http.proxyPort", <proxy-port>);

 

 

 I'm calling the login function given below

 

            Login login = new Login();
            login.setUsername(<username>);
            login.setPassword(<password>);
            LoginResult lr = binding.login(username, password);
 

 

I have added the following jars in my classpath :

 

jaxrpc.jar
axis.jar
commons-discovery-0.2.jar
commons-logging.jar
wsdl4j-1.5.1.jar
commons-httpclient-3.0-rc4.jar

I'm getting the following error while calling the login function 

 


AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode:
 faultString: java.net.UnknownHostException: test.salesforce.com
 faultActor:
 faultNode:
 faultDetail:
    {http://xml.apache.org/axis/}stackTrace:java.net.UnknownHostException: test.salesforce.com
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:153)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:120)
    at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)

 

Can someone please help me how can I resolve the problem...

 

Thanks!!!

Hi, I need some help in understanding what's going on with the outbound messaging in our case.

The web service we have built on the other end is able to receive the msg from SFDC and sends a true acknowldgement as well, but SFDC shows it as a failure with a reason "SOAP response was a nack" Anybody would know what could possibly be the reason?

Any help would be really appreciated.

Thank you!

 

 Request message 

 

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:m0="urn:sobject.enterprise.soap.sforce.com">
<SOAP-ENV:Body>
<m:notifications xmlns:m="http://soap.sforce.com/2005/09/outbound">
<m:OrganizationId>000000000000000000</m:OrganizationId>
<m:ActionId>000000000000000000</m:ActionId>
<m:SessionId>String</m:SessionId>
<m:EnterpriseUrl>String</m:EnterpriseUrl>
<m:PartnerUrl>String</m:PartnerUrl>
<m:Notification>
<m:Id>000000000000000000</m:Id>
<m:sObject>
<m0:fieldsToNull>String</m0:fieldsToNull>
<m0:Id>000000000000000000</m0:Id>
<m0:AccountId>000000000000000000</m0:AccountId>
<m0:Name>String</m0:Name>
</m:sObject>
</m:Notification>
</m:notifications>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

 

 

 Responce

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns3:notificationsResponse xmlns:ns3="http://soap.sforce.com/2005/09/outbound">
<ns3:Ack>true</ns3:Ack>
</ns3:notificationsResponse>
</soapenv:Body>
</soapenv:Envelope>

 

 

 

Message Edited by joystick on 11-11-2009 07:36 AM

Hi,

 

ISSUE :

We are using Intershop Infinity  as our App Server and We have successfully created the SoAP client. We Are able to successfully login to SF server. However we are encountering the following error of Invalid Session ID

 

Error Excerpt :

 

appserver0: An exception occured invoking service login().
appserver0: AxisFault
appserver0:  faultCode: {urn:fault.enterprise.soap.sforce.com}INVALID_SESSION_ID
appserver0:  faultSubcode:
appserver0:  faultString: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
appserver0:  faultActor:
appserver0:  faultNode:
appserver0:  faultDetail:
appserver0:  {urn:fault.enterprise.soap.sforce.com}UnexpectedErrorFault: <ns1:exceptionCode>INVALID_SESSION_ID</ns1:exceptionCode><ns1:exceptionMessage>Invalid Session ID found in SessionHeader: Illegal Session</ns1:exceptionMessage>
appserver0:
appserver0: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
appserver0:  at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:260)
appserver0:  at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:169)
appserver0:  at org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1015)
appserver0:  at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
appserver0:  at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
appserver0:  at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
appserver0:  at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
appserver0:  at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
appserver0:  at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
appserver0:  at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
appserver0:  at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
appserver0:  at javax.xml.parsers.SAXParser.parse(Unknown Source)
appserver0:  at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:242)
appserver0:  at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
appserver0:  at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
appserver0:  at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:675)
appserver0:  at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:128)
appserver0:  at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
appserver0:  at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)
appserver0:  at org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)
appserver0:  at org.apache.axis.client.AxisClient.invoke(AxisClient.java:180)
appserver0:  at org.apache.axis.client.Call.invokeEngine(Call.java:2564)
appserver0:  at org.apache.axis.client.Call.invoke(Call.java:2553)
 
CODE EXCERPT :

            Soap service = (new SforceServiceLocator()).getSoap();
           // LoginResult loginResult = service.login(username, password);
    
            SoapBindingStub binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
            binding.setTimeout(600000);
            LoginResult loginResult = binding.login(username, password);
            System.out.println("serviceResult....." + loginResult.getServerUrl());
            // Create a new session header object and set the
            // session id to that returned by the login
            binding._setProperty(
                SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY,
                loginResult.getServerUrl());
          
            // Create a new session header object and set the session id to that
            // returned by the login
            SessionHeader sh = new SessionHeader();
           
            System.out.println("Server ID: " + loginResult.getSessionId());
            System.out.println("Service name:" + new SforceServiceLocator().getServiceName());
            //sh.setSessionId(loginResult.getSessionId());
           
           binding.setHeader(
                new SforceServiceLocator().getServiceName().getNamespaceURI(),
                "SessionHeader",
                sh);
            System.out.println("SH SESS ID: " +sh.getSessionId()); 
               
          //*****************************************************************     

            Contact contact;
            SObject[] cons = new Contact[2];
          
            System.out.println("create called....3");
            for (int j = 0; j < 2; j++) {
                contact = new Contact();
                System.out.println("In loop...");
                contact.setAssistantName("Jane");
                contact.setAssistantPhone("777.777.7777");
                contact.setDepartment("Purchasing");
                contact.setDescription("International IT Purchaser");
                contact.setEmail("
joeblow@isp.com");
                contact.setFax("555.555.5555");
                contact.setMailingCity("San Mateo");
                contact.setMailingCountry("US");
                contact.setMailingState("CA");
                contact.setMailingStreet("1129 B Street");
                contact.setMailingPostalCode("94105");
                contact.setMobilePhone("888.888.8888");
                contact.setFirstName("Joe");
                contact.setLastName("Blow");
                contact.setSalutation("Mr.");
                contact.setPhone("999.999.9999");
                contact.setTitle("Purchasing Director");
                cons[j] = contact;
            }
            System.out.println("Cons length: "+cons.length);
           
           <<ERROR LINE>> SaveResult[] sr = binding.create(cons); <<ERROR LINE>>
           
            for (int j = 0; j < sr.length; j++) {
                           if (sr[j].isSuccess()) {
                               System.out.println("A contact was created with an id of: "
                                       + sr[j].getId());
                                      
                           }
               
            }

 

Please Advise.

Thanks

Saachin,

Hi

 

I have written a simple program to download the record..

Here is the progrma i have written

 

 

package com.demo;
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.sobject.*;

public class RunDemo {

    public static final String USERNAME = "";
    public static final String TOKEN = "";
    public static final String PASSWORD ="";
    
    /**
     * @param args
     */
    private SoapBindingStub binding;
    public static void main(String[] args) {
        RunDemo r = new RunDemo();
        try {
            r.login();
            r.search();
        } catch (Exception e) {
        }

    }
    

    private void login() throws Exception{
        
//        System.setProperty("http.proxySet", "true");
//        System.setProperty("http.proxyHost", "localhost");
//        System.setProperty("http.proxyPort", "8080");
//        System.setProperty("http.proxyUser", "rajiv");
//        System.setProperty("http.proxyPassword", "rajiv");
//        System.out.println("Logging into Salesforce.....");
        
        
        binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
        
        System.out.println("Before Login");
        
        LoginResult 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 Exception{
        QueryResult qr = binding.query("Select FirstName,LastName from Contact");
        if (qr.getSize() > 0){
            for (int i = 0; i < qr.getSize(); i++) {
            Contact c = (Contact) qr.getRecords(i);
            System.out.println("First Name :" + c.getFirstName() + "Last Name" + c.getLastName());
                
            }
        }
        
    }
}

 

 

 

I am getting exception on line 

 

 binding = (SoapBindingStub) new SforceServiceLocator().getSoap();

 

 

 

Here is the exception which i am getting while trying to run the program....

 

 

Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.apache.axis.client.Service.getAxisClient(Service.java:104)
    at org.apache.axis.client.Service.<init>(Service.java:113)
    at com.sforce.soap.enterprise.SforceServiceLocator.<init>(SforceServiceLocator.java:16)
    at com.demo.RunDemo.login(RunDemo.java:40)
    at com.demo.RunDemo.main(RunDemo.java:22)
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException))
    at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
    at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:370)
    at org.apache.axis.components.logger.LogFactory.getLog(LogFactory.java:37)
    at org.apache.axis.handlers.BasicHandler.<clinit>(BasicHandler.java:43)
    ... 5 more
Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException)
    at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
    at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
    ... 9 more
Caused by: java.lang.NullPointerException
    at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:374)
    ... 10 more

 

 

 

Any help on this will be great help 

 

Thanks

 

 

 

 

Hello!
I am new at writing APEX code and I need some help.   I want to write the following Excel logic in APEX CODE:

My organization has three products….let's call them "Product 1" , "Product 2", and "Product 3"

For Each Product I have a field called "Product 1 Rate", "Product 2 Rate" and "Product 3 Rate"

I want to declare a variable called "PriceDaily" and have it equal one of the product rates.

So I want to say:  If Product name is  "Product 1" than "Price Daily" is "Product 1 Rate",
                                    If Product name is  "Product 2" than "Price Daily" is "Product 2 Rate",
                                    If Product name is  "Product 3" than "Price Daily" is "Product 3 Rate"

How is this written in an APEX Class? 

Thank you for you help!!!!!!!!!

Hi,

For instance I create a new Account and I need to update its list of Contacts. What if the best way?

Is the line below correct? Thank you

 

anAccount.getContacts().getValue().getRecords().add(aContact);