• Surprise
  • NEWBIE
  • 135 Points
  • Member since 2012

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 54
    Questions
  • 86
    Replies

Please anyone explain soap with small code if available otherwise please explain about soap callout and integration

I am calling a external web service using http callouts but getting a error Callout Exception: Unrecognized SSL message. 

Hey guys, long time listener...first time caller.

 

Just beginning at Apex, need some help writing this trigger. I want a custom date field to update on the Account level whenever a Task within the Account is updated to Status=Sold.

 

The error i'm getting is "Compile Error: expecting a semi-colon, found 'Account' at line 8 column 6"

 

trigger HasSoldTask on Task (after insert) {
for (Task t: Trigger.new){
    if (t.accountID != NULL){
      acctIDs.add(t.accountID);
//Create a map to match the task related to ID's with their corresponding account ID's
      Map<ID, Account> acctMap = new Map<ID, Account> ([Select ID, Has_Sold_Opp__c from Account where ID in :acctIDs])
//Create the account object
      Account acctRec = acctMap.get(t.accountID);

//If the account ID isn't null, the subject line starts with "sw", and the task has been marked as completed
//Check to see if the Last_SW_Activity__c field is current compared with the latest completed activity    
    If ((t.Status == 'Sold') && (acctMap.get(t.accountID).Has_Sold_Opp__c < t.LastModifiedDate || acctMap.get(t.accountID).Has_Sold_Opp__c ==null)){
//Update the Last_SW_Activity__c field on the account object with the task's end date  
          acctrec.Has_Sold_Opp__c  = t.LastModifiedDate;
   
      }
  }
  update acctRec;
  }

 If I add a semi colon before " Account acctRec = acctMap.get(t.accountID);" Then I get "Compile Error: Variable does not exist: acctIDs at line 6 column 110"

 

Any ideas? Thanks!

Hi All,

 

While Sending an email to the salesforce.We got the following error.Does anybody has any idea what could cause the below given error.

 

This message was created automatically by the mail system.

A message that you sent could not be delivered to one or more of its recipients. This is a permanent error. The following address(es) failed:

>>> emailtosalesforce@jdm6g0a8jnln9wgahzdjsbwj.8dea8eae.c.le.salesforce.
>>> com (Undelivered): 551 Failed due to: SenderAuthorization

 

 

Hi All,

 

While sending an attachement as an email to be atached to the salesforce record.Salesforce is giving the below given error.

 

Is this salesforce problem or it is the Internal company server problem as I could see that error mentions server name in the error.


 #5.0.0 smtp; 552 Message is too large; 10485760 bytes max> #SMTP#

 

Thanks,

Surprise

 

 

Hi ,

 

In  salesorce to salesforce connection,after quering for records.I assume that I have few returned records.Now I want to
check the size of the records  an then do further processing.Does anyone knows how to check the size of as I am stuck here?.After querying the records have been returned in enterpriseSoapSforceCom.QueryResult g  object and size fucntion do not belong to this ,infact it belonmgs to collections.How do I this?

 

 

enterpriseSoapSforceCom.soap binding = new enterpriseSoapSforceCom.soap();
enterpriseSoapSforceCom.LoginResult lr = binding.login('jack123@yahoo.com','jackcjZCb80EPTaIce9SXTCRXpoHC');  system.debug('The value in the lr of loginresult is'+lr);
//Update the binding endpoint as per the LoginResult
binding.endpoint_x = lr.ServerUrl;
System.debug('The value after setting the binding of the binding.endpoint_x+'+binding.endpoint_x);
binding.SessionHeader = new enterpriseSoapSforceCom.SessionHeader_element();
binding.SessionHeader.sessionid=lr.sessionid;
System.debug('The value in variable of sesion id is'+binding.SessionHeader.sessionid);
String soqlQuery = 'SELECT FirstName, LastName FROM Contact';
//enterpriseSoapSforceCom.QueryResult l = binding.describeglobal();
enterpriseSoapSforceCom.QueryResult g=binding.query(soqlQuery);
                                
         
                     if (g.size() > 0)
                        {
                            
                        }    
              

Hi All,

 

I have salesforce to salesorce going on and I am trying to query an opportunity object and the end result says sucess.However,When  i try to see result in the logs I do not see result.For example,I am querying amount field on the opportunity object .

 

Is there something I am missing?

 

enterpriseSoapSforceCom.soap binding = new enterpriseSoapSforceCom.soap();
enterpriseSoapSforceCom.LoginResult lr = binding.login('james@yahoo.com','james123cjZCb80EPTaIce9SXTCRXpoHC');  
system.debug('The value in the lr of loginresult is'+lr);
//Update the binding endpoint as per the LoginResult
binding.endpoint_x = lr.ServerUrl;Spell Check
System.debug('The value after setting the binding of the binding.endpoint_x+'+binding.endpoint_x);
binding.SessionHeader = new enterpriseSoapSforceCom.SessionHeader_element();
binding.SessionHeader.sessionid=lr.sessionid;
System.debug('The value in variable of sesion id is'+binding.SessionHeader.sessionid);
string s='Select amount from opportunity limit 1';
enterpriseSoapSforceCom.QueryResult l = binding.query(s);
System.debug('The value in the variable l of type l is'+l);

Hi ,

 

Sync data between two salesforce orgs.This is what I am trying to do and we are looking for real time integration between the two salesforce org.

 

Steps:-

 

Trigger is going to call apex class future method which in turn will make a callout to webservice developed in apex in another salesforce org.

 

Now the problem is that  I can only make ten callouts from the future method.Now if the user on the opportrunity object update 10 records then webserice called in the future method will also run ten time and  on the 11th time the user will get error as number of callout allowed are over.

 

So what can I do to get rid of this limitation ? I was thinking of

 

Instead of using soap if I use rest service.Will it have same limitations applicable to it or I can send as many records I want  through the rest services without worying about the future limitations

 

Can somebody advise?

 

Thanks,

Surprise

 

 

 

Hi All,

Below given is the simple web service.This web service has been written in apex and I am calling it from Apex as I am working on two salesforce orgs.I am calling getMessage () from my org and passing opportunity name as parameter and method queries salesforce database and then return the fetched record.Uptill now it has worked fine and it works fine with one record.It generated an esception that list has more tham one row for assignement.How do I make it work with multipe records.How do I send more than one record as return value to the calling method.Can somebody please help.

 

 

 

global class Greatone  
{  
//set<string> p=new set<string>();
    WebService static String GetMessage(string msg)  
    {  
      string g;
    
       //list<string> g =new list<string>();
       opportunity opp=[select id,name from opportunity where name=:msg];
       g=string.valueof(opp);     
          
        //for(opportunity last:opp)
         //{
         
         //g=string.valueof(opp);     
         //p.add(g);
                  
         //}
         return g;  
    }
     
   
}

Hi All,

Below given is the simple web service.This web service has been written in apex and I am calling it from Apex as I am working on two salesforce orgs.I am calling getMessage () from my org and passing opportunity name as parameter and method queries salesforce database and then return the fetched record.Uptill now it has worked fine and it works fine with one record.It generated an esception that list has more tham one row for assignement.How do I make it work with multipe records.How do I send more than one record as return value to the calling method.Can somebody please help.

 

 

 

global class Greatone  
{  
//set<string> p=new set<string>();
    WebService static String GetMessage(string msg)  
    {  
      string g;
    
       //list<string> g =new list<string>();
       opportunity opp=[select id,name from opportunity where name=:msg];
       g=string.valueof(opp);     
          
        //for(opportunity last:opp)
         //{
         
         //g=string.valueof(opp);     
         //p.add(g);
                  
         //}
         return g;  
    }
     
   
}

Hi friends,

 

I am connecting salesforce with salesforce using partner wsdl.I have been able to login to the destination org from the source org and then I am caling custom webservice and passing some parameters to it which will be mapped to the account object in the destination org and then record is inserted and inserted record id  is returned as response .

 

I am running this code anonymously.

 

My problem is that after making callout ,called web service is returning an Id as reponse successfully .However,When I try to see inserted record in destination org I do not see any record over there.I am not getting any error

 

Below given code has custom web service.I have taken this webservice exactly as given in the salesforce help.

 

Can somebody please suggests

 

 

partnerSoapSforceCom.Soap sp = new partnerSoapSforceCom.Soap(); /

String username = 'james@yahoo.com'; String password = 'jamesgalore';

partnerSoapSforceCom.LoginResult loginResult = sp.login(username, password); soapSforceComSchemasClassAccountpla.Accountplan apx=new   soapSforceComSchemasClassAccountpla.Accountplan(); soapSforceComSchemasClassAccountpla.SessionHeader_element SessionHeader=new soapSforceComSchemasClassAccountpla.SessionHeader_element(); sessionHeader.sessionid=loginResult.sessionid; apx.sessionheader=sessionHeader;

soapSforceComSchemasClassAccountpla.plan l=new soapSforceComSchemasClassAccountpla.plan(); l.name='Genius'; l.Plannumber=123456;

try

{

soapSforceComSchemasClassAccountpla.Plan opp=apx.createAccountPlan(l);

system.debug('The output after value has been returned by us is' + opp);

system.debug('The value of the vplan id is' + opp.planid);

}

catch(Exception e)

{

 

System.debug('The exception has been raised is'+e);

 

}

 

 

global class AccountPlan {
       
       webservice String area;
       webservice String region;
        
       //Define an object in apex that is exposed in apex web service
       global class Plan {
          webservice String name;
          webservice Integer planNumber;
          webservice Date planningPeriod;
          webservice Id planId;
       }
    
       webservice static Plan createAccountPlan(Plan vPlan) {
            
           //A plan maps to the Account object in salesforce.com.
           //So need to map the Plan class object to Account standard object
           Account acct = new Account();
           acct.Name = vPlan.name;
           acct.AccountNumber = String.valueOf(vPlan.planNumber);
           insert acct;
            
           vPlan.planId=acct.Id;
           return vPlan;
  }
       
    
    }

 

 

Hi friends,

 

I am connecting salesforce with salesforce using partner wsdl.I have been able to login to the destination org from the source org and then I am caling custom webservice and passing some parameters to it which will be mapped to the account object in the destination org and then record is inserted and inserted record id  is returned as response .

 

I am running this code anonymously.

 

My problem is that after making callout ,called web service is returning an Id as reponse successfully .However,When I try to see inserted record in destination org I do not see any record over there.I am not getting any error

 

Below given code has custom web service.I have taken this webservice exactly as given in the salesforce help.

 

Can somebody please suggests

 

 

partnerSoapSforceCom.Soap sp = new partnerSoapSforceCom.Soap(); /

String username = 'james@yahoo.com'; String password = 'jamesgalore';

partnerSoapSforceCom.LoginResult loginResult = sp.login(username, password); soapSforceComSchemasClassAccountpla.Accountplan apx=new   soapSforceComSchemasClassAccountpla.Accountplan(); soapSforceComSchemasClassAccountpla.SessionHeader_element SessionHeader=new soapSforceComSchemasClassAccountpla.SessionHeader_element(); sessionHeader.sessionid=loginResult.sessionid; apx.sessionheader=sessionHeader;

soapSforceComSchemasClassAccountpla.plan l=new soapSforceComSchemasClassAccountpla.plan(); l.name='Genius'; l.Plannumber=123456;

try

{

soapSforceComSchemasClassAccountpla.Plan opp=apx.createAccountPlan(l);

system.debug('The output after value has been returned by us is' + opp);

system.debug('The value of the vplan id is' + opp.planid);

}

catch(Exception e)

{

 

System.debug('The exception has been raised is'+e);

 

}

 

 

global class AccountPlan {
       
       webservice String area;
       webservice String region;
        
       //Define an object in apex that is exposed in apex web service
       global class Plan {
          webservice String name;
          webservice Integer planNumber;
          webservice Date planningPeriod;
          webservice Id planId;
       }
    
       webservice static Plan createAccountPlan(Plan vPlan) {
            
           //A plan maps to the Account object in salesforce.com.
           //So need to map the Plan class object to Account standard object
           Account acct = new Account();
           acct.Name = vPlan.name;
           acct.AccountNumber = String.valueOf(vPlan.planNumber);
           insert acct;
            
           vPlan.planId=acct.Id;
           return vPlan;
  }
       
    
    }

 

 

Hi All,

Below given code is directly from the salesforce apex guide.I am trying to undersand as I have to develop some code.
 
When I generate Wsdl to Apex classes I do not see the below given class names and functions used  in the salesforce provided sample code.Wsdl to Apex class generates two classes with the names wsStrikeironCom,wwwStrikeironCom whereas I see different names for classes as well as functions in the salesforce provided sample code.  I understand that these names can be changed.Can Somebody tell me How should i decide which class to have which name so that I can use the below given sample as it is.

strikeironIplookup.DNSSoap dns=new strikeironIplookup.DNSSoap();
//
dns.LicenseInfo=new strikeiron.LicenseInfo();
dns.LicenseInfo.RegisteredUser=new strikeiron.RegisteredUser();
dns.LicenseInfo.RegisteredUser.UserID='you@company.com';
dns.LicenseInfo.RegisteredUser.Password='your-password';
strikeironIplookup.DNSInfo info=dns.DNSLookup('www.myname.co');

Hi All,
 

For connecting salesforce salesforce using Enterprise Wsdl api's,I have written the below given code.Where di i specify the code to associate URL with the session header below.Can somebody help.

 

enterpriseSoapSforceCom.LoginResult lr=new enterpriseSoapSforceCom.LoginResult();
enterpriseSoapSforceCom.soap s=new enterpriseSoapSforceCom.soap();
lr=s.login('nitins1234@yahoo.com','mummy123');
String g=lr.sessionid;
s.inputHttpHeaders_x = new Map<String, String>();
//Setting a basic authentication header
s.inputHttpHeaders_x.put('Authorization', 'g');
System.debug('The value of the session id in the new variable s is'+s);


Hi All ,

 

I am trying synchronize records from salesforce to saleforce and eveything wil be devloiped using apex.No java or c sharp.

 

Given below is the Wsdl to apex class.I am trying to use  login() api to connect to another salesforce org. I am trying it through anonymouse block.The login connection gets establised for the first time.However,I am at a total loss on how to retrieve  and assign retruned  URL and  session id .Below given is the code for login to the salesforce.How do i  create header and assign session id and server url to it so that I can call subsequent API's..Can somebody please help?

 

enterpriseSoapSforceCom.LoginResult lr=new enterpriseSoapSforceCom.LoginResult();
enterpriseSoapSforceCom.soap s=new enterpriseSoapSforceCom.soap();
lr=s.login('jack@yahoo.com','Password');

 

 

 

public class enterpriseSoapSforceCom {
    public class getUserInfo_element {
        private String[] apex_schema_type_info = new String[]{'urn:enterprise.soap.sforce.com','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class LoginResult {
        public String metadataServerUrl;
        public Boolean passwordExpired;
        public Boolean sandbox;
        public String serverUrl;
        public String sessionId;
        public String userId;
        public enterpriseSoapSforceCom.GetUserInfoResult userInfo;
        private String[] metadataServerUrl_type_info = new String[]{'metadataServerUrl','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] passwordExpired_type_info = new String[]{'passwordExpired','http://www.w3.org/2001/XMLSchema','boolean','1','1','false'};
        private String[] sandbox_type_info = new String[]{'sandbox','http://www.w3.org/2001/XMLSchema','boolean','1','1','false'};
        private String[] serverUrl_type_info = new String[]{'serverUrl','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] sessionId_type_info = new String[]{'sessionId','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] userId_type_info = new String[]{'userId','urn:enterprise.soap.sforce.com','ID','1','1','true'};
        private String[] userInfo_type_info = new String[]{'userInfo','urn:enterprise.soap.sforce.com','GetUserInfoResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:enterprise.soap.sforce.com','true','false'};
        private String[] field_order_type_info = new String[]{'metadataServerUrl','passwordExpired','sandbox','serverUrl','sessionId','userId','userInfo'};
    }
    
    public class Soap {
        public String endpoint_x = 'https://login.salesforce.com/services/Soap/c/28.0/0DFi0000000PCEo';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        public enterpriseSoapSforceCom.QueryOptions_element QueryOptions;
        public enterpriseSoapSforceCom.EmailHeader_element EmailHeader;
        public enterpriseSoapSforceCom.DebuggingInfo_element DebuggingInfo;
        public enterpriseSoapSforceCom.MruHeader_element MruHeader;
        public enterpriseSoapSforceCom.PackageVersionHeader_element PackageVersionHeader;
        public enterpriseSoapSforceCom.SessionHeader_element SessionHeader;
        public enterpriseSoapSforceCom.UserTerritoryDeleteHeader_element UserTerritoryDeleteHeader;
        public enterpriseSoapSforceCom.LoginScopeHeader_element LoginScopeHeader;
        public enterpriseSoapSforceCom.AllowFieldTruncationHeader_element AllowFieldTruncationHeader;
        public enterpriseSoapSforceCom.DebuggingHeader_element DebuggingHeader;
        public enterpriseSoapSforceCom.AllOrNoneHeader_element AllOrNoneHeader;
        public enterpriseSoapSforceCom.LocaleOptions_element LocaleOptions;
        public enterpriseSoapSforceCom.OwnerChangeOptions_element OwnerChangeOptions;
        public enterpriseSoapSforceCom.AssignmentRuleHeader_element AssignmentRuleHeader;
        public enterpriseSoapSforceCom.DisableFeedTrackingHeader_element DisableFeedTrackingHeader;
        public enterpriseSoapSforceCom.StreamingEnabledHeader_element StreamingEnabledHeader;
        private String QueryOptions_hns = 'QueryOptions=urn:enterprise.soap.sforce.com';
        private String EmailHeader_hns = 'EmailHeader=urn:enterprise.soap.sforce.com';
        private String DebuggingInfo_hns = 'DebuggingInfo=urn:enterprise.soap.sforce.com';
        private String MruHeader_hns = 'MruHeader=urn:enterprise.soap.sforce.com';
        private String PackageVersionHeader_hns = 'PackageVersionHeader=urn:enterprise.soap.sforce.com';
        private String SessionHeader_hns = 'SessionHeader=urn:enterprise.soap.sforce.com';
        private String UserTerritoryDeleteHeader_hns = 'UserTerritoryDeleteHeader=urn:enterprise.soap.sforce.com';
        private String LoginScopeHeader_hns = 'LoginScopeHeader=urn:enterprise.soap.sforce.com';
        private String AllowFieldTruncationHeader_hns = 'AllowFieldTruncationHeader=urn:enterprise.soap.sforce.com';
        private String DebuggingHeader_hns = 'DebuggingHeader=urn:enterprise.soap.sforce.com';
        private String AllOrNoneHeader_hns = 'AllOrNoneHeader=urn:enterprise.soap.sforce.com';
        private String LocaleOptions_hns = 'LocaleOptions=urn:enterprise.soap.sforce.com';
        private String OwnerChangeOptions_hns = 'OwnerChangeOptions=urn:enterprise.soap.sforce.com';
        private String AssignmentRuleHeader_hns = 'AssignmentRuleHeader=urn:enterprise.soap.sforce.com';
        private String DisableFeedTrackingHeader_hns = 'DisableFeedTrackingHeader=urn:enterprise.soap.sforce.com';
        private String StreamingEnabledHeader_hns = 'StreamingEnabledHeader=urn:enterprise.soap.sforce.com';
        private String[] ns_map_type_info = new String[]{'urn:fault.enterprise.soap.sforce.com', 'faultEnterpriseSoapSforceCom', 'urn:enterprise.soap.sforce.com', 'enterpriseSoapSforceCom', 'urn:sobject.enterprise.soap.sforce.com', 'sobjectEnterpriseSoapSforceCom'};
        public enterpriseSoapSforceCom.SearchResult search_x(String searchString) {
            enterpriseSoapSforceCom.search_element request_x = new enterpriseSoapSforceCom.search_element();
            enterpriseSoapSforceCom.searchResponse_element response_x;
            request_x.searchString = searchString;
            Map<String, enterpriseSoapSforceCom.searchResponse_element> response_map_x = new Map<String, enterpriseSoapSforceCom.searchResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'urn:enterprise.soap.sforce.com',
              'search',
              'urn:enterprise.soap.sforce.com',
              'searchResponse',
              'enterpriseSoapSforceCom.searchResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.result;
        
            public enterpriseSoapSforceCom.LoginResult login(String username,String password) {
            enterpriseSoapSforceCom.login_element request_x = new enterpriseSoapSforceCom.login_element();
            enterpriseSoapSforceCom.loginResponse_element response_x;
            request_x.username = username;
            request_x.password = password;
            Map<String, enterpriseSoapSforceCom.loginResponse_element> response_map_x = new Map<String, enterpriseSoapSforceCom.loginResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'urn:enterprise.soap.sforce.com',
              'login',
              'urn:enterprise.soap.sforce.com',
              'loginResponse',
              'enterpriseSoapSforceCom.loginResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.result;
        }
            
            
        }
        
        
        }

Hi All,

 

Is it possible to connect my developer org with Database.com using enterprise WSDl.  I am trying to generate classes from database.com enterprise wsdl  in my developer org but I get the following error..Can somebody please help.

 

Apex Generation FailedUnsupported schema type: {http://www.w3.org/2001/XMLSchema}anyType

Hi All,

 

While writing an apex web service,do I need to worry about soap envelope,header ,body and more importantly Payload  or all this gets created in background by Apex and I should just focus on writing a web service using apex.

 

Will it be a good idea to use external id to query records in salesforce.External id will belong to some other sytem not to salesforce.

 

Thanks,

Surprise

Hi All,

 

Do we have this Anti-forgery feature automatically incorporated in all the pages in which we have included form tag on the visual force page?.


After going through the stuff at the below given URL,It looks like we do not have to make any changes to the existing pages.It looks like that this feature once enabled by salesforce will atimatically embed some token in the page and all post

request will be automaticlally verified by the salesforce.

 

Can somebody confirm that I am thinking right?

 

http://wiki.developerforce.com/page/Secure_Coding_Cross_Site_Request_Forgery#Apex_and_Visualforce_Applications

Hi,

 

We have tons of VF pages in salesforce and now see some security update.How should I use this security update.We have pages and then salesforce portal which is accessible to outside public.Now am I suppose to make changes to all the pages as some pages are accessed by the company salesforce internal users and some are accessible to the outside public on the portal .If that is the case then I have to create a form on each and every page with hidden form field and some characters stored in it .Now can somebody please tell me how these characters will me matched.

 

Or

 

This thing has to be done only on the pages which form created on the page.Can somebdy please advise?

 

 

 

Anti-CSRF token

 

 

 

 

 

 

Salesforce.com has implemented an anti-CSRF token to prevent Cross Site Request Forgery attacks.

Turning on these preferences ensures that non-setup pages include a random string of characters in the URL parameters or as a hidden form field.

Upon GET and POST requests, the application checks the validity of this string of characters and does not execute the command unless the value matches the expected value.

Salesforce.com enabled validation checks for CSRF tokens in the Summer '10 release.

Hi Friends,


I have taken Below given sample from teh salesforce help as it is .All I need to understand upsert fuinctionality so that I can use it in my own project.

 

Below example is creating two accounts and setting some values in the Externalid field along with the other values and then storing those records in the the array in the 1 and 2 index position of the array and then using connection.upsert and providing externalid and array as arguments For example,

 

Connection.upsert("MyExtId__c", upserts);

 

My Question ,From where is connection.upsert () function geting externalid value.Can somebody please help.

 

 

 

This sample upserts two accounts using a custom external ID field called MyExtId__c. The upsert() call matches the accounts based on the MyExtId__c field in order to determine whether to create or update the accounts. Before running this sample, change the MyExtId__c field name to an existing custom ID field name in your org.

 

public void upsertRecords() {

   SObject[] upserts = new Account[2];

 

   Account upsertAccount1 = new Account();

   upsertAccount1.setName("Begonia");

   upsertAccount1.setIndustry("Education");

   upsertAccount1.setMyExtId__c("1111111111");

   upserts[0] = upsertAccount1;

 

   Account upsertAccount2 = new Account();

   upsertAccount2 = new Account();

   upsertAccount2.setName("Bluebell");

   upsertAccount2.setIndustry("Technology");

   upsertAccount2.setMyExtId__c("2222222222");

   upserts[1] = upsertAccount2;

 

   try {

      // Invoke the upsert call and save the results.

      // Use External_Id custom field for matching records.

      UpsertResult[] upsertResults = connection.upsert(

                                  "MyExtId__c", upserts);

      for (UpsertResult result : upsertResults) {

         if (result.isSuccess()) {

            System.out.println("\nUpsert succeeded.");

            System.out.println((result.isCreated() ? "Insert" : "Update")

                  + " was performed.");

            System.out.println("Account ID: " + result.getId());

         } else {

            System.out.println("The Upsert failed because: "

                  + result.getErrors()[0].getMessage());

         }

      }

   } catch (ConnectionException ce) {

      ce.printStackTrace();

   }

 

Hi All,

 

If I write webservices in salesforce and comsumed by somebody else then that person will parse xml reponse before doing anyhting else.Is that correct?

 

While writing webservcie in salesorce.Do I need to write any XMl anywhere or its get's generated in the background by the force.com platform and I need not worry about it.?I should simply create webservcie in salesorce and that's it.

 

Can somebody please answer as early as possible?

 

 

Thanks,

Surprise

Hi friends,

 

Will the below given code handle multiple records inserted from data loader.? If i insert one record from salesforce user interface trigger.new wil have one reocord probably stored at index zero and then it passes to the list of type book__c variable books andf record get stored at the zero index in the books variable..

 

 

Now if I use data loader ,keeping the same code as it is .I insert 20 records.How will this code behave? .Will all the records be stored in trigger.new variable at different index starting from 0,1,2..........19  and then same records will be asisgned to the book varible ,First records from trigger.new will be strored at index 0 in the book variable and record number 2 from trigger.new variable will be stored at index 1 of the book variable.Am I thinking  right ?can somebody validate?

 

trigger HelloWorld12 on Book__c(before insert)
{

Book__c[]books=trigger.new;
MyHelloWorld1.applydiscount(books);

}

Hi All ,

 

For connecting two systems for integration, which Oauth mechaninsm will be the best .

 

 

 

User in x system will not be user's in Y system.Basically ,no common users.Both the systems are independent and I am trying to connect them .

 

 

1)Since users in both the systems are not common,so can sombody tell me the best Oauth which I can use.

 

I was thinking that,for example ,I can create a new user account in salesforce and then I can use that user name ,password and security token in the code in other system to get session id.So any user in y system logs in  and generate some event then based on that event ,code in the background will execute, which will connect to saleforce using salesforce username,password and  and token mentioned in the code and  this will happen in the background.

 

 

Another alternative which may not work in this scenario.

 

Since users in x system and Y system are not common ,therefore, user in system y cannot be presented with the salesforce login screen where user will punch in its credentials and then salesforce authorizing it  .Am I thinking right ?

 

Please suggests?

 

What do u think should be the best Authorization mechaniosm when user are not common to both the systems.

 

 

Hi ,

 

In  salesorce to salesforce connection,after quering for records.I assume that I have few returned records.Now I want to
check the size of the records  an then do further processing.Does anyone knows how to check the size of as I am stuck here?.After querying the records have been returned in enterpriseSoapSforceCom.QueryResult g  object and size fucntion do not belong to this ,infact it belonmgs to collections.How do I this?

 

 

enterpriseSoapSforceCom.soap binding = new enterpriseSoapSforceCom.soap();
enterpriseSoapSforceCom.LoginResult lr = binding.login('jack123@yahoo.com','jackcjZCb80EPTaIce9SXTCRXpoHC');  system.debug('The value in the lr of loginresult is'+lr);
//Update the binding endpoint as per the LoginResult
binding.endpoint_x = lr.ServerUrl;
System.debug('The value after setting the binding of the binding.endpoint_x+'+binding.endpoint_x);
binding.SessionHeader = new enterpriseSoapSforceCom.SessionHeader_element();
binding.SessionHeader.sessionid=lr.sessionid;
System.debug('The value in variable of sesion id is'+binding.SessionHeader.sessionid);
String soqlQuery = 'SELECT FirstName, LastName FROM Contact';
//enterpriseSoapSforceCom.QueryResult l = binding.describeglobal();
enterpriseSoapSforceCom.QueryResult g=binding.query(soqlQuery);
                                
         
                     if (g.size() > 0)
                        {
                            
                        }    
              

Hi All,

 

I have salesforce to salesorce going on and I am trying to query an opportunity object and the end result says sucess.However,When  i try to see result in the logs I do not see result.For example,I am querying amount field on the opportunity object .

 

Is there something I am missing?

 

enterpriseSoapSforceCom.soap binding = new enterpriseSoapSforceCom.soap();
enterpriseSoapSforceCom.LoginResult lr = binding.login('james@yahoo.com','james123cjZCb80EPTaIce9SXTCRXpoHC');  
system.debug('The value in the lr of loginresult is'+lr);
//Update the binding endpoint as per the LoginResult
binding.endpoint_x = lr.ServerUrl;Spell Check
System.debug('The value after setting the binding of the binding.endpoint_x+'+binding.endpoint_x);
binding.SessionHeader = new enterpriseSoapSforceCom.SessionHeader_element();
binding.SessionHeader.sessionid=lr.sessionid;
System.debug('The value in variable of sesion id is'+binding.SessionHeader.sessionid);
string s='Select amount from opportunity limit 1';
enterpriseSoapSforceCom.QueryResult l = binding.query(s);
System.debug('The value in the variable l of type l is'+l);

Looked and looked online, in communites and through my cookbook and cannot seem to figure it out - so hoping the collective community can help find the error.

 

I have a custom button that is calling an apex class.  I get the dreaded "fault code....etc.  No operation available for request, etc...  please check the WSDL for the service."

 

My understanding of this error is that the apex code being called is not declared as a webservice.  However in my case it is, but with @future.  

 

Here is the code in the button:

{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}

if (
 (
// System Administrator
 ("{!$User.ProfileId}" == "00e30000000e1mu") ||
// Order Management
 ("{!$User.ProfileId}" == "00e30000000i5Km")
 ) && "{!Opportunity.Probability}" >= .75 ) {

var oppID = '{!Opportunity.Id}';
var man = true;

sforce.apex.execute("oppClose","createCase",{oppID: oppID, man: true});

location.reload();

}

else

{
alert("Only Authorized Users can manually trigger the creation of all necessary //Cases for Implementation and only from a Closed Won Opportunity");
}

 


Here is the snippet of code from the apex class that is being called where the webservice is defined:

 

global class OppClose {
    public static String koAmericanPrnCaseId;
    public static String koBeehiveCaseId;
    public static String koHarcourtCaseId;
    public static String koJohnsonCaseId;
    public static String koRidgwaysCaseId;
    public static String koMondoCaseId;
    public static ID cntct;
    public static Integer count;
    public static ID impCase;
    public static ID pbeID;
    @future
    webService static void createCase(ID oppID, Boolean man){
      
       List<Opportunity> oppList =
        [select o.AssdImpCase__c, .....  etc.

 

 

Hi All,

Below given is the simple web service.This web service has been written in apex and I am calling it from Apex as I am working on two salesforce orgs.I am calling getMessage () from my org and passing opportunity name as parameter and method queries salesforce database and then return the fetched record.Uptill now it has worked fine and it works fine with one record.It generated an esception that list has more tham one row for assignement.How do I make it work with multipe records.How do I send more than one record as return value to the calling method.Can somebody please help.

 

 

 

global class Greatone  
{  
//set<string> p=new set<string>();
    WebService static String GetMessage(string msg)  
    {  
      string g;
    
       //list<string> g =new list<string>();
       opportunity opp=[select id,name from opportunity where name=:msg];
       g=string.valueof(opp);     
          
        //for(opportunity last:opp)
         //{
         
         //g=string.valueof(opp);     
         //p.add(g);
                  
         //}
         return g;  
    }
     
   
}

Hi friends,

 

I am connecting salesforce with salesforce using partner wsdl.I have been able to login to the destination org from the source org and then I am caling custom webservice and passing some parameters to it which will be mapped to the account object in the destination org and then record is inserted and inserted record id  is returned as response .

 

I am running this code anonymously.

 

My problem is that after making callout ,called web service is returning an Id as reponse successfully .However,When I try to see inserted record in destination org I do not see any record over there.I am not getting any error

 

Below given code has custom web service.I have taken this webservice exactly as given in the salesforce help.

 

Can somebody please suggests

 

 

partnerSoapSforceCom.Soap sp = new partnerSoapSforceCom.Soap(); /

String username = 'james@yahoo.com'; String password = 'jamesgalore';

partnerSoapSforceCom.LoginResult loginResult = sp.login(username, password); soapSforceComSchemasClassAccountpla.Accountplan apx=new   soapSforceComSchemasClassAccountpla.Accountplan(); soapSforceComSchemasClassAccountpla.SessionHeader_element SessionHeader=new soapSforceComSchemasClassAccountpla.SessionHeader_element(); sessionHeader.sessionid=loginResult.sessionid; apx.sessionheader=sessionHeader;

soapSforceComSchemasClassAccountpla.plan l=new soapSforceComSchemasClassAccountpla.plan(); l.name='Genius'; l.Plannumber=123456;

try

{

soapSforceComSchemasClassAccountpla.Plan opp=apx.createAccountPlan(l);

system.debug('The output after value has been returned by us is' + opp);

system.debug('The value of the vplan id is' + opp.planid);

}

catch(Exception e)

{

 

System.debug('The exception has been raised is'+e);

 

}

 

 

global class AccountPlan {
       
       webservice String area;
       webservice String region;
        
       //Define an object in apex that is exposed in apex web service
       global class Plan {
          webservice String name;
          webservice Integer planNumber;
          webservice Date planningPeriod;
          webservice Id planId;
       }
    
       webservice static Plan createAccountPlan(Plan vPlan) {
            
           //A plan maps to the Account object in salesforce.com.
           //So need to map the Plan class object to Account standard object
           Account acct = new Account();
           acct.Name = vPlan.name;
           acct.AccountNumber = String.valueOf(vPlan.planNumber);
           insert acct;
            
           vPlan.planId=acct.Id;
           return vPlan;
  }
       
    
    }

 

 

Hi friends,

 

I am connecting salesforce with salesforce using partner wsdl.I have been able to login to the destination org from the source org and then I am caling custom webservice and passing some parameters to it which will be mapped to the account object in the destination org and then record is inserted and inserted record id  is returned as response .

 

I am running this code anonymously.

 

My problem is that after making callout ,called web service is returning an Id as reponse successfully .However,When I try to see inserted record in destination org I do not see any record over there.I am not getting any error

 

Below given code has custom web service.I have taken this webservice exactly as given in the salesforce help.

 

Can somebody please suggests

 

 

partnerSoapSforceCom.Soap sp = new partnerSoapSforceCom.Soap(); /

String username = 'james@yahoo.com'; String password = 'jamesgalore';

partnerSoapSforceCom.LoginResult loginResult = sp.login(username, password); soapSforceComSchemasClassAccountpla.Accountplan apx=new   soapSforceComSchemasClassAccountpla.Accountplan(); soapSforceComSchemasClassAccountpla.SessionHeader_element SessionHeader=new soapSforceComSchemasClassAccountpla.SessionHeader_element(); sessionHeader.sessionid=loginResult.sessionid; apx.sessionheader=sessionHeader;

soapSforceComSchemasClassAccountpla.plan l=new soapSforceComSchemasClassAccountpla.plan(); l.name='Genius'; l.Plannumber=123456;

try

{

soapSforceComSchemasClassAccountpla.Plan opp=apx.createAccountPlan(l);

system.debug('The output after value has been returned by us is' + opp);

system.debug('The value of the vplan id is' + opp.planid);

}

catch(Exception e)

{

 

System.debug('The exception has been raised is'+e);

 

}

 

 

global class AccountPlan {
       
       webservice String area;
       webservice String region;
        
       //Define an object in apex that is exposed in apex web service
       global class Plan {
          webservice String name;
          webservice Integer planNumber;
          webservice Date planningPeriod;
          webservice Id planId;
       }
    
       webservice static Plan createAccountPlan(Plan vPlan) {
            
           //A plan maps to the Account object in salesforce.com.
           //So need to map the Plan class object to Account standard object
           Account acct = new Account();
           acct.Name = vPlan.name;
           acct.AccountNumber = String.valueOf(vPlan.planNumber);
           insert acct;
            
           vPlan.planId=acct.Id;
           return vPlan;
  }
       
    
    }

 

 

I developed  simple soap api from one of my org and consumed it in another one ....

 

When i am calling it from another org ....it gives me the below error

First error: Web service callout failed: WebService returned a SOAP Fault: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session faultcode=sf:INVALID_SESSION_ID faultactor=

 

public class LogInfo {
public String category;
public String level;
private String[] category_type_info = new String[]{'category','http://soap.sforce.com/schemas/class/MyWebService','LogCategory','1','1','false'};
private String[] level_type_info = new String[]{'level','http://soap.sforce.com/schemas/class/MyWebService','LogCategoryLevel','1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/MyWebService','true','false'};
private String[] field_order_type_info = new String[]{'category','level'};

 

public class LoginHistory {
public String ApiType;
public String ApiVersion;
public String Application;
public String Browser;
public String ClientVersion;
public DateTime LoginTime;
public String LoginType;
public String LoginUrl;
public String Platform;
public String SourceIp;
public String Status;
public String UserId;
private String[] ApiType_type_info = new String[]{'ApiType','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] ApiVersion_type_info = new String[]{'ApiVersion','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] Application_type_info = new String[]{'Application','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] Browser_type_info = new String[]{'Browser','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] ClientVersion_type_info = new String[]{'ClientVersion','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] LoginTime_type_info = new String[]{'LoginTime','http://www.w3.org/2001/XMLSchema','dateTime','0','1','true'};
private String[] LoginType_type_info = new String[]{'LoginType','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] LoginUrl_type_info = new String[]{'LoginUrl','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] Platform_type_info = new String[]{'Platform','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] SourceIp_type_info = new String[]{'SourceIp','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] Status_type_info = new String[]{'Status','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] UserId_type_info = new String[]{'UserId','http://soap.sforce.com/schemas/class/MyWebService','ID','0','1','true'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/MyWebService','true','false'};
private String[] field_order_type_info = new String[]{'ApiType','ApiVersion','Application','Browser','ClientVersion','LoginTime','LoginType','LoginUrl','Platform','SourceIp','Status','UserId'};
}

 

 

public class LoginIp {
public DateTime ChallengeSentDate;
public DateTime CreatedDate;
public Boolean IsAuthenticated;
public String SourceIp;
public MYWebservice34.User_x Users;
public String UsersId;
private String[] ChallengeSentDate_type_info = new String[]{'ChallengeSentDate','http://www.w3.org/2001/XMLSchema','dateTime','0','1','true'};
private String[] CreatedDate_type_info = new String[]{'CreatedDate','http://www.w3.org/2001/XMLSchema','dateTime','0','1','true'};
private String[] IsAuthenticated_type_info = new String[]{'IsAuthenticated','http://www.w3.org/2001/XMLSchema','boolean','0','1','true'};
private String[] SourceIp_type_info = new String[]{'SourceIp','http://www.w3.org/2001/XMLSchema','string','0','1','true'};
private String[] Users_type_info = new String[]{'Users','http://soap.sforce.com/schemas/class/MyWebService','User','0','1','true'};
private String[] UsersId_type_info = new String[]{'UsersId','http://soap.sforce.com/schemas/class/MyWebService','ID','0','1','true'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/MyWebService','true','false'};
private String[] field_order_type_info = new String[]{'ChallengeSentDate','CreatedDate','IsAuthenticated','SourceIp','Users','UsersId'};
}

 

 

how to rectify the error?????

THanks

Hi All,

 

I am trying to integrate salesforce with salesforce.I have generated wsdl to apex using enterprise wsdl.Now in the another org when I try to connect using salesforce login API,I am able to connect and then I am setting up headers so that I can call more api's.However,I have to pass new URL after retrieving it from the s object of the soap class.However,I am not able to figure out how to send this URL while calling more API's .Can somebody help?

 

 

enterpriseSoapSforceCom.LoginResult lr=new enterpriseSoapSforceCom.LoginResult();
enterpriseSoapSforceCom.soap s=new enterpriseSoapSforceCom.soap();

lr=s.login('Craig@yahoo.com',Lastric);
String g=lr.sessionid;
System.debug('The value of the session id in the new variable s is'+g);
//string url=lr.serverurl;
//lr.serverurl;
//system.debug('The value of the url in the new variable s is'+url);
s.inputHttpHeaders_x = new Map<String, String>();
//Setting a basic authentication header
s.inputHttpHeaders_x.put('Authorization', 'g');//Here i am supplying the session id
//s.inputHttpHeaders_x .put('New Url',url);//Here I tried to pass the URL in the header but it di not work.
enterpriseSoapSforceCom.QueryResult qResult=new enterpriseSoapSforceCom.QueryResult();
qResult = null;

String soqlQuery='SELECT name FROM Contact';
qResult = s.query(soqlQuery);
System.debug('The value of the contact object opp is'+qResult);



 

 

 

 

 

 

public class enterpriseSoapSforceCom {
    public class getUserInfo_element {
        private String[] apex_schema_type_info = new String[]{'urn:enterprise.soap.sforce.com','true','

false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class LoginResult {
        public String metadataServerUrl;
        public Boolean passwordExpired;
        public Boolean sandbox;
        public String serverUrl;
        public String sessionId;
        public String userId;
        public enterpriseSoapSforceCom.GetUserInfoResult userInfo;
        private String[] metadataServerUrl_type_info = new String[]{'metadataServerUrl','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] passwordExpired_type_info = new String[]{'passwordExpired','http://www.w3.org/2001/XMLSchema','boolean','1','1','false'};
        private String[] sandbox_type_info = new String[]{'sandbox','http://www.w3.org/2001/XMLSchema','boolean','1','1','false'};
        private String[] serverUrl_type_info = new String[]{'serverUrl','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] sessionId_type_info = new String[]{'sessionId','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] userId_type_info = new String[]{'userId','urn:enterprise.soap.sforce.com','ID','1','1','true'};
        private String[] userInfo_type_info = new String[]{'userInfo','urn:enterprise.soap.sforce.com','GetUserInfoResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:enterprise.soap.sforce.com','true','false'};
        private String[] field_order_type_info = new String[]{'metadataServerUrl','passwordExpired','sandbox','serverUrl','sessionId','userId','userInfo'};
    }
    
    public class Soap {
        public String endpoint_x = 'https://login.salesforce.com/services/Soap/c/28.0/0DFi0000000PCEo';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        public enterpriseSoapSforceCom.QueryOptions_element QueryOptions;
        public enterpriseSoapSforceCom.EmailHeader_element EmailHeader;
        public enterpriseSoapSforceCom.DebuggingInfo_element DebuggingInfo;
        public enterpriseSoapSforceCom.MruHeader_element MruHeader;
        public enterpriseSoapSforceCom.PackageVersionHeader_element PackageVersionHeader;
        public enterpriseSoapSforceCom.SessionHeader_element SessionHeader;
        public enterpriseSoapSforceCom.UserTerritoryDeleteHeader_element UserTerritoryDeleteHeader;
        public enterpriseSoapSforceCom.LoginScopeHeader_element LoginScopeHeader;
        public enterpriseSoapSforceCom.AllowFieldTruncationHeader_element AllowFieldTruncationHeader;
        public enterpriseSoapSforceCom.DebuggingHeader_element DebuggingHeader;
        public enterpriseSoapSforceCom.AllOrNoneHeader_element AllOrNoneHeader;
        public enterpriseSoapSforceCom.LocaleOptions_element LocaleOptions;
        public enterpriseSoapSforceCom.OwnerChangeOptions_element OwnerChangeOptions;
        public enterpriseSoapSforceCom.AssignmentRuleHeader_element AssignmentRuleHeader;
        public enterpriseSoapSforceCom.DisableFeedTrackingHeader_element DisableFeedTrackingHeader;
        public enterpriseSoapSforceCom.StreamingEnabledHeader_element StreamingEnabledHeader;
        private String QueryOptions_hns = 'QueryOptions=urn:enterprise.soap.sforce.com';
        private String EmailHeader_hns = 'EmailHeader=urn:enterprise.soap.sforce.com';
        private String DebuggingInfo_hns = 'DebuggingInfo=urn:enterprise.soap.sforce.com';
        private String MruHeader_hns = 'MruHeader=urn:enterprise.soap.sforce.com';
        private String PackageVersionHeader_hns = 'PackageVersionHeader=urn:enterprise.soap.sforce.com';
        private String SessionHeader_hns = 'SessionHeader=urn:enterprise.soap.sforce.com';
        private String UserTerritoryDeleteHeader_hns = 'UserTerritoryDeleteHeader=urn:enterprise.soap.sforce.com';
        private String LoginScopeHeader_hns = 'LoginScopeHeader=urn:enterprise.soap.sforce.com';
        private String AllowFieldTruncationHeader_hns = 'AllowFieldTruncationHeader=urn:enterprise.soap.sforce.com';
        private String DebuggingHeader_hns = 'DebuggingHeader=urn:enterprise.soap.sforce.com';
        private String AllOrNoneHeader_hns = 'AllOrNoneHeader=urn:enterprise.soap.sforce.com';
        private String LocaleOptions_hns = 'LocaleOptions=urn:enterprise.soap.sforce.com';
        private String OwnerChangeOptions_hns = 'OwnerChangeOptions=urn:enterprise.soap.sforce.com';
        private String AssignmentRuleHeader_hns = 'AssignmentRuleHeader=urn:enterprise.soap.sforce.com';
        private String DisableFeedTrackingHeader_hns = 'DisableFeedTrackingHeader=urn:enterprise.soap.sforce.com';
        private String StreamingEnabledHeader_hns = 'StreamingEnabledHeader=urn:enterprise.soap.sforce.com';
        private String[] ns_map_type_info = new String[]{'urn:fault.enterprise.soap.sforce.com', 'faultEnterpriseSoapSforceCom', 'urn:enterprise.soap.sforce.com', 'enterpriseSoapSforceCom', 'urn:sobject.enterprise.soap.sforce.com', 'sobjectEnterpriseSoapSforceCom'};
        public enterpriseSoapSforceCom.SearchResult search_x(String searchString) {
            enterpriseSoapSforceCom.search_element request_x = new enterpriseSoapSforceCom.search_element();
            enterpriseSoapSforceCom.searchResponse_element response_x;
            request_x.searchString = searchString;
            Map<String, enterpriseSoapSforceCom.searchResponse_element> response_map_x = new Map<String, enterpriseSoapSforceCom.searchResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'urn:enterprise.soap.sforce.com',
              'search',
              'urn:enterprise.soap.sforce.com',
              'searchResponse',
              'enterpriseSoapSforceCom.searchResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.result;
        
            public enterpriseSoapSforceCom.LoginResult login(String username,String password) {
            enterpriseSoapSforceCom.login_element request_x = new enterpriseSoapSforceCom.login_element();
            enterpriseSoapSforceCom.loginResponse_element response_x;
            request_x.username = username;
            request_x.password = password;
            Map<String, enterpriseSoapSforceCom.loginResponse_element> response_map_x = new Map<String, enterpriseSoapSforceCom.loginResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'urn:enterprise.soap.sforce.com',
              'login',
              'urn:enterprise.soap.sforce.com',
              'loginResponse',
              'enterpriseSoapSforceCom.loginResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.result;
        }
            
            
        }
        
        
        }

 

 

 

 

 

 

Hi All,
 

For connecting salesforce salesforce using Enterprise Wsdl api's,I have written the below given code.Where di i specify the code to associate URL with the session header below.Can somebody help.

 

enterpriseSoapSforceCom.LoginResult lr=new enterpriseSoapSforceCom.LoginResult();
enterpriseSoapSforceCom.soap s=new enterpriseSoapSforceCom.soap();
lr=s.login('nitins1234@yahoo.com','mummy123');
String g=lr.sessionid;
s.inputHttpHeaders_x = new Map<String, String>();
//Setting a basic authentication header
s.inputHttpHeaders_x.put('Authorization', 'g');
System.debug('The value of the session id in the new variable s is'+s);


Hi All ,

 

I am trying synchronize records from salesforce to saleforce and eveything wil be devloiped using apex.No java or c sharp.

 

Given below is the Wsdl to apex class.I am trying to use  login() api to connect to another salesforce org. I am trying it through anonymouse block.The login connection gets establised for the first time.However,I am at a total loss on how to retrieve  and assign retruned  URL and  session id .Below given is the code for login to the salesforce.How do i  create header and assign session id and server url to it so that I can call subsequent API's..Can somebody please help?

 

enterpriseSoapSforceCom.LoginResult lr=new enterpriseSoapSforceCom.LoginResult();
enterpriseSoapSforceCom.soap s=new enterpriseSoapSforceCom.soap();
lr=s.login('jack@yahoo.com','Password');

 

 

 

public class enterpriseSoapSforceCom {
    public class getUserInfo_element {
        private String[] apex_schema_type_info = new String[]{'urn:enterprise.soap.sforce.com','true','false'};
        private String[] field_order_type_info = new String[]{};
    }
    public class LoginResult {
        public String metadataServerUrl;
        public Boolean passwordExpired;
        public Boolean sandbox;
        public String serverUrl;
        public String sessionId;
        public String userId;
        public enterpriseSoapSforceCom.GetUserInfoResult userInfo;
        private String[] metadataServerUrl_type_info = new String[]{'metadataServerUrl','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] passwordExpired_type_info = new String[]{'passwordExpired','http://www.w3.org/2001/XMLSchema','boolean','1','1','false'};
        private String[] sandbox_type_info = new String[]{'sandbox','http://www.w3.org/2001/XMLSchema','boolean','1','1','false'};
        private String[] serverUrl_type_info = new String[]{'serverUrl','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] sessionId_type_info = new String[]{'sessionId','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] userId_type_info = new String[]{'userId','urn:enterprise.soap.sforce.com','ID','1','1','true'};
        private String[] userInfo_type_info = new String[]{'userInfo','urn:enterprise.soap.sforce.com','GetUserInfoResult','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:enterprise.soap.sforce.com','true','false'};
        private String[] field_order_type_info = new String[]{'metadataServerUrl','passwordExpired','sandbox','serverUrl','sessionId','userId','userInfo'};
    }
    
    public class Soap {
        public String endpoint_x = 'https://login.salesforce.com/services/Soap/c/28.0/0DFi0000000PCEo';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        public enterpriseSoapSforceCom.QueryOptions_element QueryOptions;
        public enterpriseSoapSforceCom.EmailHeader_element EmailHeader;
        public enterpriseSoapSforceCom.DebuggingInfo_element DebuggingInfo;
        public enterpriseSoapSforceCom.MruHeader_element MruHeader;
        public enterpriseSoapSforceCom.PackageVersionHeader_element PackageVersionHeader;
        public enterpriseSoapSforceCom.SessionHeader_element SessionHeader;
        public enterpriseSoapSforceCom.UserTerritoryDeleteHeader_element UserTerritoryDeleteHeader;
        public enterpriseSoapSforceCom.LoginScopeHeader_element LoginScopeHeader;
        public enterpriseSoapSforceCom.AllowFieldTruncationHeader_element AllowFieldTruncationHeader;
        public enterpriseSoapSforceCom.DebuggingHeader_element DebuggingHeader;
        public enterpriseSoapSforceCom.AllOrNoneHeader_element AllOrNoneHeader;
        public enterpriseSoapSforceCom.LocaleOptions_element LocaleOptions;
        public enterpriseSoapSforceCom.OwnerChangeOptions_element OwnerChangeOptions;
        public enterpriseSoapSforceCom.AssignmentRuleHeader_element AssignmentRuleHeader;
        public enterpriseSoapSforceCom.DisableFeedTrackingHeader_element DisableFeedTrackingHeader;
        public enterpriseSoapSforceCom.StreamingEnabledHeader_element StreamingEnabledHeader;
        private String QueryOptions_hns = 'QueryOptions=urn:enterprise.soap.sforce.com';
        private String EmailHeader_hns = 'EmailHeader=urn:enterprise.soap.sforce.com';
        private String DebuggingInfo_hns = 'DebuggingInfo=urn:enterprise.soap.sforce.com';
        private String MruHeader_hns = 'MruHeader=urn:enterprise.soap.sforce.com';
        private String PackageVersionHeader_hns = 'PackageVersionHeader=urn:enterprise.soap.sforce.com';
        private String SessionHeader_hns = 'SessionHeader=urn:enterprise.soap.sforce.com';
        private String UserTerritoryDeleteHeader_hns = 'UserTerritoryDeleteHeader=urn:enterprise.soap.sforce.com';
        private String LoginScopeHeader_hns = 'LoginScopeHeader=urn:enterprise.soap.sforce.com';
        private String AllowFieldTruncationHeader_hns = 'AllowFieldTruncationHeader=urn:enterprise.soap.sforce.com';
        private String DebuggingHeader_hns = 'DebuggingHeader=urn:enterprise.soap.sforce.com';
        private String AllOrNoneHeader_hns = 'AllOrNoneHeader=urn:enterprise.soap.sforce.com';
        private String LocaleOptions_hns = 'LocaleOptions=urn:enterprise.soap.sforce.com';
        private String OwnerChangeOptions_hns = 'OwnerChangeOptions=urn:enterprise.soap.sforce.com';
        private String AssignmentRuleHeader_hns = 'AssignmentRuleHeader=urn:enterprise.soap.sforce.com';
        private String DisableFeedTrackingHeader_hns = 'DisableFeedTrackingHeader=urn:enterprise.soap.sforce.com';
        private String StreamingEnabledHeader_hns = 'StreamingEnabledHeader=urn:enterprise.soap.sforce.com';
        private String[] ns_map_type_info = new String[]{'urn:fault.enterprise.soap.sforce.com', 'faultEnterpriseSoapSforceCom', 'urn:enterprise.soap.sforce.com', 'enterpriseSoapSforceCom', 'urn:sobject.enterprise.soap.sforce.com', 'sobjectEnterpriseSoapSforceCom'};
        public enterpriseSoapSforceCom.SearchResult search_x(String searchString) {
            enterpriseSoapSforceCom.search_element request_x = new enterpriseSoapSforceCom.search_element();
            enterpriseSoapSforceCom.searchResponse_element response_x;
            request_x.searchString = searchString;
            Map<String, enterpriseSoapSforceCom.searchResponse_element> response_map_x = new Map<String, enterpriseSoapSforceCom.searchResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'urn:enterprise.soap.sforce.com',
              'search',
              'urn:enterprise.soap.sforce.com',
              'searchResponse',
              'enterpriseSoapSforceCom.searchResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.result;
        
            public enterpriseSoapSforceCom.LoginResult login(String username,String password) {
            enterpriseSoapSforceCom.login_element request_x = new enterpriseSoapSforceCom.login_element();
            enterpriseSoapSforceCom.loginResponse_element response_x;
            request_x.username = username;
            request_x.password = password;
            Map<String, enterpriseSoapSforceCom.loginResponse_element> response_map_x = new Map<String, enterpriseSoapSforceCom.loginResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'urn:enterprise.soap.sforce.com',
              'login',
              'urn:enterprise.soap.sforce.com',
              'loginResponse',
              'enterpriseSoapSforceCom.loginResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.result;
        }
            
            
        }
        
        
        }

Hi,

 

I'm working on my first trigger and test, and I think I got through most of the problems in the code, but I keep failing to validate them. In the developer console it tells me that the trigger has a 100% on all tests,but as you can see, this is not how the program reads it when validating.

 

Attached are the fails I get, and the modified code:

 

TestDontDelete.myUnitTest() - Failure Message: "System.QueryException: List has more than 1 row for assignment to SObject", Failure Stack Trace: "Class.TestDontDelete.myUnitTest: line 7, column 1"
 
dontDelete - Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required.
 
Deploy Error - Average test coverage across all Apex Classes and Triggers is 0%, at least 75% test coverage is required.

 

Trigger:

 

//Prevent deleting a contact that is associated with a 203k disbursement

trigger dontDelete on Contact (before delete)
{
  RecordType r =[Select id, name from RecordType where SobjectType='Contact' and name='Contractor'];
  for (Contact x : Trigger.old)
  {
    if (x.RecordTypeId==r.id)
    {
      x.addError('You cannot delete this an account of type "Contractor"');
    }
  }
}

 

Test:

 

@isTest
private class TestDontDelete
{
  static testMethod void myUnitTest()
  {

    Contact con = new Contact (LastName = 'Testi', RecordTypeID= [SELECT Id FROM RecordType WHERE Name = 'Contractor'].Id);

    try
    {
      delete con;
    }
  catch (dmlexception e)
  {
    system.assert(e.getMessage().contains('You cannot delete this an account of type "Contractor"'),
    e.getMessage());
  }
}
}

  • July 01, 2013
  • Like
  • 0

Hi All,

 

While writing an apex web service,do I need to worry about soap envelope,header ,body and more importantly Payload  or all this gets created in background by Apex and I should just focus on writing a web service using apex.

 

Will it be a good idea to use external id to query records in salesforce.External id will belong to some other sytem not to salesforce.

 

Thanks,

Surprise

Hi Friends,


I have taken Below given sample from teh salesforce help as it is .All I need to understand upsert fuinctionality so that I can use it in my own project.

 

Below example is creating two accounts and setting some values in the Externalid field along with the other values and then storing those records in the the array in the 1 and 2 index position of the array and then using connection.upsert and providing externalid and array as arguments For example,

 

Connection.upsert("MyExtId__c", upserts);

 

My Question ,From where is connection.upsert () function geting externalid value.Can somebody please help.

 

 

 

This sample upserts two accounts using a custom external ID field called MyExtId__c. The upsert() call matches the accounts based on the MyExtId__c field in order to determine whether to create or update the accounts. Before running this sample, change the MyExtId__c field name to an existing custom ID field name in your org.

 

public void upsertRecords() {

   SObject[] upserts = new Account[2];

 

   Account upsertAccount1 = new Account();

   upsertAccount1.setName("Begonia");

   upsertAccount1.setIndustry("Education");

   upsertAccount1.setMyExtId__c("1111111111");

   upserts[0] = upsertAccount1;

 

   Account upsertAccount2 = new Account();

   upsertAccount2 = new Account();

   upsertAccount2.setName("Bluebell");

   upsertAccount2.setIndustry("Technology");

   upsertAccount2.setMyExtId__c("2222222222");

   upserts[1] = upsertAccount2;

 

   try {

      // Invoke the upsert call and save the results.

      // Use External_Id custom field for matching records.

      UpsertResult[] upsertResults = connection.upsert(

                                  "MyExtId__c", upserts);

      for (UpsertResult result : upsertResults) {

         if (result.isSuccess()) {

            System.out.println("\nUpsert succeeded.");

            System.out.println((result.isCreated() ? "Insert" : "Update")

                  + " was performed.");

            System.out.println("Account ID: " + result.getId());

         } else {

            System.out.println("The Upsert failed because: "

                  + result.getErrors()[0].getMessage());

         }

      }

   } catch (ConnectionException ce) {

      ce.printStackTrace();

   }

 

Hi All,

 

If I write webservices in salesforce and comsumed by somebody else then that person will parse xml reponse before doing anyhting else.Is that correct?

 

While writing webservcie in salesorce.Do I need to write any XMl anywhere or its get's generated in the background by the force.com platform and I need not worry about it.?I should simply create webservcie in salesorce and that's it.

 

Can somebody please answer as early as possible?

 

 

Thanks,

Surprise

Hi All ,

 

For connecting two systems for integration, which Oauth mechaninsm will be the best .

 

 

 

User in x system will not be user's in Y system.Basically ,no common users.Both the systems are independent and I am trying to connect them .

 

 

1)Since users in both the systems are not common,so can sombody tell me the best Oauth which I can use.

 

I was thinking that,for example ,I can create a new user account in salesforce and then I can use that user name ,password and security token in the code in other system to get session id.So any user in y system logs in  and generate some event then based on that event ,code in the background will execute, which will connect to saleforce using salesforce username,password and  and token mentioned in the code and  this will happen in the background.

 

 

Another alternative which may not work in this scenario.

 

Since users in x system and Y system are not common ,therefore, user in system y cannot be presented with the salesforce login screen where user will punch in its credentials and then salesforce authorizing it  .Am I thinking right ?

 

Please suggests?

 

What do u think should be the best Authorization mechaniosm when user are not common to both the systems.

 

 

Hi Friends,

 

Since we are working on analytics outside our salesforce system.Therefore,we have to read data from salesforce and use it outsifde salesforce to create analytics .

 

My Question:-Outside vendor has to get into salesforce and read data from it.Can somebody tell me steps on how to go about it.

My idea is that outside vendor has to login to salesforce.In order to accomplish that.

Do I need to.

 

1)Give  enterpriswe url or partner url to them   

3) So once they have been able to log in to the salesforce then how are they going to read data or pull out data from salesforce.Are there any API'S which they have to use to read data from salesforce? 

 

Guys, please suggests. 

 

Thanks

 

 

 

  • April 15, 2013
  • Like
  • 0

Hi all,

 

Am integrating twitter through salseforce but response failed and am getting below error

 

"failed to validate oauth signature and token"

 

 

Am passing accesstoken,secretkey and ect like this

 

Can any one help or suggest ?

 

string Stringval='OAuth oauth_callback="'+EncodingUtil.urlEncode('https://c.ap1.visual.force.com/apex/twitterForcepage', 'UTF-8')+'",oauth_consumer_key="eIGzjmMGeclmpSzxmjnKhQ", oauth_nonce="3de317379683f90d4f80da8879472036", oauth_signature="fiyY68Llzy2yREjUeJw0o%2Fdqcns%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1365504459", oauth_token="354671694-MrReLR18pmpDZulKaRVZR3CifKpI9ZFo1XUofyJn", oauth_version="1.0"';


string bVal=EncodingUtil.Base64Encode(blob.valueof(Stringval)); 
        String authorizationHeader = 'Bearer :' + bval;
        req.setHeader('Authorization',bVal);




 

 

Thanks in Advance.

Hi ,

 

  My scenario is , if i create a employee details record in in salesforce , It will be Display in SAP/PI. 

 

  Employee objects

 

  Fields - Name,Ename__c & Salary__c

 

  Steps:

1) generate Apex class from sap/pi WSDL

2) create a new apex class (future methods ) and set enerated class end point.

3) write a trigger , to call future methods apex class

   

Generated Apex class from SAP PI system

 

public class intrigoSoapSforceCom456 {
    public class HTTPS_Port {
        public String endpoint_x = 'http://ca-in02:520/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_SFDCTEST&receiverParty=&receiverService=&interface=SI_SFDC_OUT&interfaceNamespace=urn:intrigo.soap.sforce.com';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'urn:intrigo.soap.sforce.com', 'intrigoSoapSforceCom456'};
        public intrigoSoapSforceCom456.Response_element[] SI_SFDC_OUT(intrigoSoapSforceCom456.Employee_element[] Employee) {
            intrigoSoapSforceCom456.SfdcTest_Request request_x = new intrigoSoapSforceCom456.SfdcTest_Request();
            intrigoSoapSforceCom456.SFDCResponse response_x;
            request_x.Employee = Employee;
            Map<String, intrigoSoapSforceCom456.SFDCResponse> response_map_x = new Map<String, intrigoSoapSforceCom456.SFDCResponse>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://sap.com/xi/WebService/soap1.1',
              'urn:intrigo.soap.sforce.com',
              'MT_SFDC_Request',
              'urn:intrigo.soap.sforce.com',
              'MT_SFDC_Response',
              'intrigoSoapSforceCom456.SFDCResponse'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.Response;
        }
    }
    public class Response_element {
        public String sapno;
        private String[] sapno_type_info = new String[]{'sapno','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:intrigo.soap.sforce.com','false','false'};
        private String[] field_order_type_info = new String[]{'sapno'};
    }
    public class SFDCResponse {
        public intrigoSoapSforceCom456.Response_element[] Response;
        private String[] Response_type_info = new String[]{'Response','urn:intrigo.soap.sforce.com','Response_element','1','-1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:intrigo.soap.sforce.com','false','false'};
        private String[] field_order_type_info = new String[]{'Response'};
    }
    public class Employee_element {
        public String EmployeeNo;
        public String Ename;
        public String Salary;
        private String[] EmployeeNo_type_info = new String[]{'EmployeeNo','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Ename_type_info = new String[]{'Ename','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] Salary_type_info = new String[]{'Salary','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:intrigo.soap.sforce.com','false','false'};
        private String[] field_order_type_info = new String[]{'EmployeeNo','Ename','Salary'};
    }
    public class SfdcTest_Request {
        public intrigoSoapSforceCom456.Employee_element[] Employee;
        private String[] Employee_type_info = new String[]{'Employee','urn:intrigo.soap.sforce.com','Employee_element','1','-1','false'};
        private String[] apex_schema_type_info = new String[]{'urn:intrigo.soap.sforce.com','false','false'};
        private String[] field_order_type_info = new String[]{'Employee'};
    }
}

 

 

Apex class :

 

global class WebServiceCallout123 {
 
    @future (callout=true)
    WebService static void sendNotification(String EmployeeNo ,String Ename, String Salary) {
     //Set your username and password here
        String username = 'nreddy';
        String password = 'sappi123';
 
        //Construct HTTP request and response
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        
         //Construct Authorization and Content header
        Blob headerValue = Blob.valueOf(username+':'+password);
        String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);
       req.setHeader('Content-Type','application/json');
        
         //Set Method and Endpoint and Body
        req.setMethod('POST');
        req.setEndpoint('http://ca-in02:520/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_SFDCTEST&receiverParty=&receiverService=&interface=SI_SFDC_OUT&interfaceNamespace=urn:intrigo.soap.sforce.com');
        
        req.setBody('{"EmployeeNo":"'+EmployeeNo+'","ename":"'+ename+'","Salary":"'+Salary+'"}');
        System.debug('EmployeeNo -->' + EmployeeNo); 
        try {
           //Send endpoint to JIRA
           res = http.send(req);
            
        } catch(System.CalloutException e) {
            System.debug(res.toString());
        }
    }

 

    
    public static testMethod void testMe() {
        WebServiceCallout123.sendNotification('aza','aza','aza');
    }
 
}

 

trigger:

 

trigger InsertEcc on Employee__c (after Insert) {

for(Employee__c s:Trigger.New)
{
   
     WebServiceCallout123.sendNotification(s.Name,s.Ename__c,s.Salary__c);
     System.debug('Emp data -->' + s);

 

}

}

 

The problem is it is not affected in sap /pi. Any body have a idea. what wrong i done? please help me