• Streepeye
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 11
    Replies

I would like to delete records using a external key.

But the delete operation from the APEX DATALOADER won't let me use the external key as key for deletion!

 

So, what is the way to delete records via an external key?

 

 

Message Edited by Streepeye on 03-31-2009 06:22 AM

Hi there,

I am trying to create a trigger on a custom object "VerwijderFnc__c" what deletes records in another custom object "Functionaris__c"

 

process is: insert a record into VerwijderFnc__c and get the Id from the Functionaris__c to delete those Functionaris__c record(s).

Sometimes i get more then 20 records as a result! and that is too much!

 

so i try to make this trigger bulksafe .... But i can't get ik to work for me !

This was 1e my code for the trigger: (NOT BULKSAFE)

 

trigger deleteFromFunctionaris on VerwijderFnc__c (before insert) {
     for(VerwijderFnc__c verwijdertabel: Trigger.new){
         for (Functionaris__c fs: [SELECT Id FROM Functionaris__c WHERE mskey__c = :verwijdertabel.MSkey__c]){
            //Delete all the Functionaris__c entries with given mskey__c
            delete fs;
         }
     }
}

 

then i tried something like: (BUT ALSO GIVES TOO MANYDML STATMENTS)

 

trigger deleteFromFunctionaris on VerwijderFnc__c (before insert) {

 

Map<String, VerwijderFnc__c> fncMap = new Map<String, VerwijderFnc__c>(); for (VerwijderFnc__c fnc : System.Trigger.new) {  if ((fnc.mskey__c != null) && (System.Trigger.isInsert || (fnc.mskey__c != System.Trigger.oldMap.get(fnc.Id).mskey__c))) {

fncMap.put(fnc.mskey__c, fnc);

}

}

 

for (Functionaris__c func : [SELECT Id FROM Functionaris__c WHERE mskey__c IN :fncMap.KeySet()]) { delete func;

}

}

 

 

 

!! Help !!

 

 

 

Message Edited by Streepeye on 03-31-2009 05:56 AM

I have a apexclass which calls an external webservice...

with the response i  am updating and inserting in the account object...

 

after everything has been updated and inserted i call the same webservice again with an other operation to tell the webservice that everything has been Done !

 

When i call the webservice with the other operation i get the "You have uncommitted work pending..." error.

 

Why...

How can i call the webservice after i inserted and updated....?

(i want to call the webservice after the updates and inserts because only then i know if everything went well!)

 

I want to set the sessionId value in the header of the Upsert operation

with the value i just got from the Login operation.

 

I am new in java, i don't know how to get the value to set it again in the header  

 

 

 

this is the my generated java code:

 

/**
 * SalesForceAgent_EnterpriceService.java
 *
 * This file was generated by LANSA Integrator SOAP Agent Wizard
 */
package com.marktselect.service.soap ;

public class SalesForceAgent_EnterpriceService implements com.lansa.jsm.service.SOAPAgentHandler
{

    /*
        Operation - login
    */

    public final void setOperation_LOGIN ()
    {
    }

    /*
        Operation Request - login
    */

    public final void prepareRequest_LOGIN ( com.lansa.jsm.service.SOAPAgentRequest request ) throws Exception
    {
        request.prepareParameter ( "USERNAME", java.lang.String.class, false, false ) ;
        request.prepareParameter ( "PASSWORD", java.lang.String.class, false, false ) ;
    }

    /*
        Operation Parameter - login
    */

    public final void setParameter_LOGIN_USERNAME ( com.lansa.jsm.service.SOAPAgentParameter parameter, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception
    {
        parameter.setEntity ( bind.getFieldValue ( "MSLOGUSR" ), null, null ) ;
    }

    /*
        Operation Parameter - login
    */

    public final void setParameter_LOGIN_PASSWORD ( com.lansa.jsm.service.SOAPAgentParameter parameter, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception
    {
        parameter.setEntity ( bind.getFieldValue ( "MSLOGPWD" ), null, null ) ;
    }

    /*
        Operation Response - login
    */

    public final void prepareResponse_LOGIN ( com.lansa.jsm.service.SOAPAgentResponse response ) throws Exception
    {
        response.prepareFragment ( new String[] { "LOGIN" }, com.sforce.soap.enterprise.LoginResult.class, false, true, null ) ;
        response.prepareFragment ( new String[] { "LOGIN", "USERINFO" }, com.sforce.soap.enterprise.GetUserInfoResult.class, false, true, "getUserInfo" ) ;
    }

    /*
        Operation Fragment - login
    */

    public final void getFragment_LOGIN_LOGIN ( com.lansa.jsm.service.SOAPAgentResponseFragment fragment, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception
    {
        bind.setFieldValue ( "URLSERVER", fragment.getEntity ( "metadataServerUrl", null ) ) ;
        bind.setFieldValue ( "PWEXPIRED", fragment.getEntity ( "passwordExpired", null ) ) ;
        bind.setFieldValue ( "SANDBOX", fragment.getEntity ( "sandbox", null ) ) ;
        bind.setFieldValue ( "SERVERURL", fragment.getEntity ( "serverUrl", null ) ) ;
        bind.setFieldValue ( "SESSIONID", fragment.getEntity ( "sessionId", null ) ) ;
        bind.setFieldValue ( "USERID", fragment.getEntity ( "userId", null ) ) ;
    }

    /*
        Operation Fragment - login
    */

    public final void getFragment_LOGIN_USERINFO ( com.lansa.jsm.service.SOAPAgentResponseFragment fragment, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception
    {
        bind.setFieldValue ( "ACCMODE", fragment.getEntity ( "accessibilityMode", null ) ) ;
        bind.setFieldValue ( "CURSYMBOL", fragment.getEntity ( "currencySymbol", null ) ) ;
        bind.setFieldValue ( "ORGISOCOD", fragment.getEntity ( "orgDefaultCurrencyIsoCode", null ) ) ;
        bind.setFieldValue ( "PERSACC", fragment.getEntity ( "orgHasPersonAccounts", null ) ) ;
        bind.setFieldValue ( "ORGID", fragment.getEntity ( "organizationId", null ) ) ;
        bind.setFieldValue ( "ORGMLTCUR", fragment.getEntity ( "organizationMultiCurrency", null ) ) ;
        bind.setFieldValue ( "MSBEDRNM", fragment.getEntity ( "organizationName", null ) ) ;
        bind.setFieldValue ( "MSPROFILE", fragment.getEntity ( "profileId", null ) ) ;
        bind.setFieldValue ( "ROLEID", fragment.getEntity ( "roleId", null ) ) ;
        bind.setFieldValue ( "DEFCURCOD", fragment.getEntity ( "userDefaultCurrencyIsoCode", null ) ) ;
        bind.setFieldValue ( "MSEMAIL", fragment.getEntity ( "userEmail", null ) ) ;
        bind.setFieldValue ( "MSFULLNM", fragment.getEntity ( "userFullName", null ) ) ;
        bind.setFieldValue ( "MSUSRID", fragment.getEntity ( "userId", null ) ) ;
        bind.setFieldValue ( "USERLANG", fragment.getEntity ( "userLanguage", null ) ) ;
        bind.setFieldValue ( "USERLOCAL", fragment.getEntity ( "userLocale", null ) ) ;
        bind.setFieldValue ( "USRNAME", fragment.getEntity ( "userName", null ) ) ;
        bind.setFieldValue ( "TIMEZONE", fragment.getEntity ( "userTimeZone", null ) ) ;
        bind.setFieldValue ( "MSUSRTYPE", fragment.getEntity ( "userType", null ) ) ;
        bind.setFieldValue ( "UISKIN", fragment.getEntity ( "userUiSkin", null ) ) ;
    }

    /*
        Operation Return - login
    */

    public final void getReturnParameter_LOGIN ( com.lansa.jsm.service.SOAPAgentResponse response, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception
    {
    }

    /*
        Operation Call - login
    */

    public final com.lansa.jsm.service.SOAPAgentResponse callOperation_LOGIN ( com.lansa.jsm.service.SOAPAgentRequest request, String user, String password, String url ) throws Exception
    {
        com.sforce.soap.enterprise.SforceServiceLocator locator = new com.sforce.soap.enterprise.SforceServiceLocator () ;

        String endPoint = locator.getSoapAddress () ;

        if ( url != null )
        {
            endPoint = url ;
        }

        com.sforce.soap.enterprise.SoapBindingStub stub = (com.sforce.soap.enterprise.SoapBindingStub)locator.getSoap ( new java.net.URL ( endPoint ) ) ;

        if ( user != null && password != null )
        {
            stub.setUsername ( user ) ;

            stub.setPassword ( password ) ;
        }

/*

    Add SOAP header

*/


org.apache.axis.message.SOAPHeaderElement elementHead = new org.apache.axis.message.SOAPHeaderElement ("", "SessionHeader");
 

javax.xml.soap.SOAPElement elementsessionId = elementHead.addChildElement ( "sessionId" ) ;

elementsessionId.addTextNode ( "HOW DO I GET THE SESSIONID IN HERE?" );

stub.setHeader ( elementHead ) ;

 

/*

   End SOAP header
*/

        request.traceStub ( stub ) ;

        return new com.lansa.jsm.service.SOAPAgentResponse ( stub.login( request.getParameterValueString ( "USERNAME" ), request.getParameterValueString ( "PASSWORD" ) ) ) ;
    }

    /*
        Operation - upsert
    */

    public final void setOperation_UPSERT ()
    {
    }

    /*
        Operation Request - upsert
    */

    public final void prepareRequest_UPSERT ( com.lansa.jsm.service.SOAPAgentRequest request ) throws Exception
    {
        request.prepareParameter ( "EXTERNALIDFIELDNAME", java.lang.String.class, false, false ) ;
        request.prepareParameter ( "SOBJECTS", com.sforce.soap.enterprise.sobject.SObject.class, true, true ) ;
        request.prepareFragment ( "SOBJECTS", new String[] { "UPSERTOBJ" }, com.sforce.soap.enterprise.sobject.SObject.class, true, true, null ) ;
        request.prepareList ( "SOBJECTS", new String[] { "UPSERTOBJ", "OBJNAME" }, java.lang.String.class, true, false, "setFieldsToNull" ) ;
    }

    /*
        Operation Parameter - upsert
    */

    public final void setParameter_UPSERT_EXTERNALIDFIELDNAME ( com.lansa.jsm.service.SOAPAgentParameter parameter,

 

    etc... 

 

 

 

 

this is the my generated message i sent:

 

 

<?xml version="1.0" encoding="UTF-8" ?>
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Header>
- <SessionHeader soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0">
  <sessionId>HOW DO I GET THE SESSIONID IN HERE?</sessionId>
  </SessionHeader>
  </soapenv:Header>
- <soapenv:Body>
- <upsert xmlns="urn:enterprise.soap.sforce.com">
  <externalIDFieldName>mskey__c</externalIDFieldName>
- <sObjects>
  <ns1:fieldsToNull xmlns:ns1="urn:sobject.enterprise.soap.sforce.com">34</ns1:fieldsToNull>
  <ns2:Id xmlns:ns2="urn:sobject.enterprise.soap.sforce.com">11111</ns2:Id>
  </sObjects>
  </upsert>
  </soapenv:Body>
  </soapenv:Envelope>

Hi, I want to set the sessionid header element in the upsert operation! but i don't know how,... i am quit new with java. i get a header element but i dont know how to set the value which i just got from the login operation? see below "Add SOAP header" here is my generated java code: /** * SalesForceAgent_EnterpriceService.java * * This file was generated by LANSA Integrator SOAP Agent Wizard */ package com.marktselect.service.soap ; public class SalesForceAgent_EnterpriceService implements com.lansa.jsm.service.SOAPAgentHandler { /* Operation - login */ public final void setOperation_LOGIN () { } /* Operation Request - login */ public final void prepareRequest_LOGIN ( com.lansa.jsm.service.SOAPAgentRequest request ) throws Exception { request.prepareParameter ( "USERNAME", java.lang.String.class, false, false ) ; request.prepareParameter ( "PASSWORD", java.lang.String.class, false, false ) ; } /* Operation Parameter - login */ public final void setParameter_LOGIN_USERNAME ( com.lansa.jsm.service.SOAPAgentParameter parameter, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { parameter.setEntity ( bind.getFieldValue ( "MSLOGUSR" ), null, null ) ; } /* Operation Parameter - login */ public final void setParameter_LOGIN_PASSWORD ( com.lansa.jsm.service.SOAPAgentParameter parameter, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { parameter.setEntity ( bind.getFieldValue ( "MSLOGPWD" ), null, null ) ; } /* Operation Response - login */ public final void prepareResponse_LOGIN ( com.lansa.jsm.service.SOAPAgentResponse response ) throws Exception { response.prepareFragment ( new String[] { "LOGIN" }, com.sforce.soap.enterprise.LoginResult.class, false, true, null ) ; response.prepareFragment ( new String[] { "LOGIN", "USERINFO" }, com.sforce.soap.enterprise.GetUserInfoResult.class, false, true, "getUserInfo" ) ; } /* Operation Fragment - login */ public final void getFragment_LOGIN_LOGIN ( com.lansa.jsm.service.SOAPAgentResponseFragment fragment, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { bind.setFieldValue ( "URLSERVER", fragment.getEntity ( "metadataServerUrl", null ) ) ; bind.setFieldValue ( "PWEXPIRED", fragment.getEntity ( "passwordExpired", null ) ) ; bind.setFieldValue ( "SANDBOX", fragment.getEntity ( "sandbox", null ) ) ; bind.setFieldValue ( "SERVERURL", fragment.getEntity ( "serverUrl", null ) ) ; bind.setFieldValue ( "SESSIONID", fragment.getEntity ( "sessionId", null ) ) ; bind.setFieldValue ( "USERID", fragment.getEntity ( "userId", null ) ) ; } /* Operation Fragment - login */ public final void getFragment_LOGIN_USERINFO ( com.lansa.jsm.service.SOAPAgentResponseFragment fragment, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { bind.setFieldValue ( "ACCMODE", fragment.getEntity ( "accessibilityMode", null ) ) ; bind.setFieldValue ( "CURSYMBOL", fragment.getEntity ( "currencySymbol", null ) ) ; bind.setFieldValue ( "ORGISOCOD", fragment.getEntity ( "orgDefaultCurrencyIsoCode", null ) ) ; bind.setFieldValue ( "PERSACC", fragment.getEntity ( "orgHasPersonAccounts", null ) ) ; bind.setFieldValue ( "ORGID", fragment.getEntity ( "organizationId", null ) ) ; bind.setFieldValue ( "ORGMLTCUR", fragment.getEntity ( "organizationMultiCurrency", null ) ) ; bind.setFieldValue ( "MSBEDRNM", fragment.getEntity ( "organizationName", null ) ) ; bind.setFieldValue ( "MSPROFILE", fragment.getEntity ( "profileId", null ) ) ; bind.setFieldValue ( "ROLEID", fragment.getEntity ( "roleId", null ) ) ; bind.setFieldValue ( "DEFCURCOD", fragment.getEntity ( "userDefaultCurrencyIsoCode", null ) ) ; bind.setFieldValue ( "MSEMAIL", fragment.getEntity ( "userEmail", null ) ) ; bind.setFieldValue ( "MSFULLNM", fragment.getEntity ( "userFullName", null ) ) ; bind.setFieldValue ( "MSUSRID", fragment.getEntity ( "userId", null ) ) ; bind.setFieldValue ( "USERLANG", fragment.getEntity ( "userLanguage", null ) ) ; bind.setFieldValue ( "USERLOCAL", fragment.getEntity ( "userLocale", null ) ) ; bind.setFieldValue ( "USRNAME", fragment.getEntity ( "userName", null ) ) ; bind.setFieldValue ( "TIMEZONE", fragment.getEntity ( "userTimeZone", null ) ) ; bind.setFieldValue ( "MSUSRTYPE", fragment.getEntity ( "userType", null ) ) ; bind.setFieldValue ( "UISKIN", fragment.getEntity ( "userUiSkin", null ) ) ; } /* Operation Return - login */ public final void getReturnParameter_LOGIN ( com.lansa.jsm.service.SOAPAgentResponse response, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { } /* Operation Call - login */ public final com.lansa.jsm.service.SOAPAgentResponse callOperation_LOGIN ( com.lansa.jsm.service.SOAPAgentRequest request, String user, String password, String url ) throws Exception { com.sforce.soap.enterprise.SforceServiceLocator locator = new com.sforce.soap.enterprise.SforceServiceLocator () ; String endPoint = locator.getSoapAddress () ; if ( url != null ) { endPoint = url ; } com.sforce.soap.enterprise.SoapBindingStub stub = (com.sforce.soap.enterprise.SoapBindingStub)locator.getSoap ( new java.net.URL ( endPoint ) ) ; if ( user != null && password != null ) { stub.setUsername ( user ) ; stub.setPassword ( password ) ; } /* Add SOAP header */ org.apache.axis.message.SOAPHeaderElement elementHead = new org.apache.axis.message.SOAPHeaderElement ("", "SessionHeader"); javax.xml.soap.SOAPElement elementsessionId = elementHead.addChildElement ( "sessionId" ) ; elementsessionId.addTextNode ( "HOW DO I GET THE SESSIONID IN HERE?" ); stub.setHeader ( elementHead ) ; /* End SOAP header */ request.traceStub ( stub ) ; return new com.lansa.jsm.service.SOAPAgentResponse ( stub.login( request.getParameterValueString ( "USERNAME" ), request.getParameterValueString ( "PASSWORD" ) ) ) ; } /* Operation - upsert */ public final void setOperation_UPSERT () { } /* Operation Request - upsert */ public final void prepareRequest_UPSERT ( com.lansa.jsm.service.SOAPAgentRequest request ) throws Exception { request.prepareParameter ( "EXTERNALIDFIELDNAME", java.lang.String.class, false, false ) ; request.prepareParameter ( "SOBJECTS", com.sforce.soap.enterprise.sobject.SObject.class, true, true ) ; request.prepareFragment ( "SOBJECTS", new String[] { "UPSERTOBJ" }, com.sforce.soap.enterprise.sobject.SObject.class, true, true, null ) ; request.prepareList ( "SOBJECTS", new String[] { "UPSERTOBJ", "OBJNAME" }, java.lang.String.class, true, false, "setFieldsToNull" ) ; } /* Operation Parameter - upsert */ public final void setParameter_UPSERT_EXTERNALIDFIELDNAME ( com.lansa.jsm.service.SOAPAgentParameter parameter, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { parameter.setEntity ( bind.getFieldValue ( "EXTFLDNM" ), null, null ) ; } /* Operation Parameter - upsert */ public final void setParameter_UPSERT_SOBJECTS ( com.lansa.jsm.service.SOAPAgentParameter parameter, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { } /* Operation Fragment - upsert */ public final void setFragment_UPSERT_SOBJECTS_UPSERTOBJ ( com.lansa.jsm.service.SOAPAgentRequestFragment fragment, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { fragment.setEntity ( "id", bind.getFieldValue ( "SFIDSTR" ), null, null ) ; } public final com.lansa.jsm.service.SOAPAgentList setList_UPSERT_UPSERTOBJ_OBJNAME () throws Exception { return new com.lansa.jsm.service.SOAPAgentList ( new String[] { "OBJELEM" }, new String[] { "entry" }, new com.lansa.jsm.service.SOAPEntityFormat[] { null } ) ; } /* Operation Response - upsert */ public final void prepareResponse_UPSERT ( com.lansa.jsm.service.SOAPAgentResponse response ) throws Exception { response.prepareFragment ( new String[] { "UPSERTRESULT" }, com.sforce.soap.enterprise.UpsertResult.class, true, true, null ) ; response.prepareFragment ( new String[] { "UPSERTRESULT", "ERRORS" }, com.sforce.soap.enterprise.Error.class, true, true, "getErrors" ) ; response.prepareList ( new String[] { "UPSERTRESULT", "ERRORS", "OBJRETLST" }, java.lang.String.class, true, false, "getFields" ) ; } /* Operation Fragment - upsert */ public final void getFragment_UPSERT_UPSERTRESULT ( com.lansa.jsm.service.SOAPAgentResponseFragment fragment, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { bind.setFieldValue ( "ISCREATED", fragment.getEntity ( "created", null ) ) ; bind.setFieldValue ( "SFRETID", fragment.getEntity ( "id", null ) ) ; bind.setFieldValue ( "ISSUCCES", fragment.getEntity ( "success", null ) ) ; } /* Operation Fragment - upsert */ public final void getFragment_UPSERT_ERRORS ( com.lansa.jsm.service.SOAPAgentResponseFragment fragment, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { bind.setFieldValue ( "MSERRMSG", fragment.getEntity ( "message", null ) ) ; bind.setFieldValue ( "MSERRCODS", fragment.getEntity ( "statusCode", null ) ) ; } public final com.lansa.jsm.service.SOAPAgentList getList_UPSERT_ERRORS_OBJRETLST () throws Exception { return new com.lansa.jsm.service.SOAPAgentList ( new String[] { "OBJELEM" }, new String[] { "entry" }, new com.lansa.jsm.service.SOAPEntityFormat[] { null } ) ; } /* Operation Return - upsert */ public final void getReturnParameter_UPSERT ( com.lansa.jsm.service.SOAPAgentResponse response, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { } /* Operation Call - upsert */ public final com.lansa.jsm.service.SOAPAgentResponse callOperation_UPSERT ( com.lansa.jsm.service.SOAPAgentRequest request, String user, String password, String url ) throws Exception { com.sforce.soap.enterprise.SforceServiceLocator locator = new com.sforce.soap.enterprise.SforceServiceLocator () ; String endPoint = locator.getSoapAddress () ; if ( url != null ) { endPoint = url ; } com.sforce.soap.enterprise.SoapBindingStub stub = (com.sforce.soap.enterprise.SoapBindingStub)locator.getSoap ( new java.net.URL ( endPoint ) ) ; if ( user != null && password != null ) { stub.setUsername ( user ) ; stub.setPassword ( password ) ; } /* Add SOAP header */ org.apache.axis.message.SOAPHeaderElement elementHead = new org.apache.axis.message.SOAPHeaderElement ("", "SessionHeader"); javax.xml.soap.SOAPElement elementsessionId = elementHead.addChildElement ( "sessionId" ) ; elementsessionId.addTextNode ( "HOW DO I GET THE SESSIONID IN HERE?" ); stub.setHeader ( elementHead ) ; /* End SOAP header */ request.traceStub ( stub ) ; return new com.lansa.jsm.service.SOAPAgentResponse ( stub.upsert( request.getParameterValueString ( "EXTERNALIDFIELDNAME" ), (com.sforce.soap.enterprise.sobject.SObject[])request.getParameterValueObject ( "SOBJECTS" ) ) ) ; } } this is the generated reguest: - - - HOW DO I GET THE SESSIONID IN HERE? - - mskey__c - 34 11111

i try to usert something with de enterprise.wsdl

 

i am getting the following error when i request the UPSERT operation

 

Does anybody knows where this is refering to / what goes wrong or what doe i have to give a value?

 

 THE REQUEST

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com" xmlns:urn1="urn:sobject.enterprise.soap.sforce.com">
   <soapenv:Header>
      <urn:EmailHeader>
         <urn:triggerAutoResponseEmail></urn:triggerAutoResponseEmail>
         <urn:triggerOtherEmail></urn:triggerOtherEmail>
         <urn:triggerUserEmail></urn:triggerUserEmail>
      </urn:EmailHeader>
      <urn:DebuggingHeader>
         <urn:debugLevel></urn:debugLevel>
      </urn:DebuggingHeader>
      <urn:MruHeader>
         <urn:updateMru></urn:updateMru>
      </urn:MruHeader>
      <urn:AssignmentRuleHeader>
         <urn:assignmentRuleId></urn:assignmentRuleId>
         <urn:useDefaultRule></urn:useDefaultRule>
      </urn:AssignmentRuleHeader>
      <urn:SessionHeader>
         <urn:sessionId>fp6KrNsQwVjKNplTnn4CN2xd</urn:sessionId>
      </urn:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <urn:upsert>
        <urn:externalIDFieldName>mskey__c</urn:externalIDFieldName>
        <urn:sObjects xsi:type="NewRBScodes__c">
           <mskey__c>1</mskey__c>
           <Name>000002</Name>
           <rlcode__c>340</rlcode__c>
        </urn:sObjects>
      </urn:upsert>
   </soapenv:Body>
</soapenv:Envelope> 

 

 

 

THE RESPONSE

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>soapenv:Client</faultcode>
         <faultstring>'' is not a valid value for the enum 'LogType'</faultstring>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>

I am trying to cummunicate with a external webservice, but i can't get my wrapper class to work!

i think it has to do something with the return values... there are 3 return elements...!?

 

i want to call the NewAccount operation... 

 

could anybody tell me how to write the wrapper for this wsdl?

 

 

 

 

THIS IS THE WSDL

 

//Generated by wsdl2apex

public class soapserver_MS_SFService {
    public class NewAccount {
        public Integer errorCode;
        public String errorMessage;
        public Integer mskey;
        public Integer relatiecode;
        private String[] errorCode_type_info = new String[]{'errorCode','http://www.w3.org/2001/XMLSchema','int','1','1','false'};
        private String[] errorMessage_type_info = new String[]{'errorMessage','http://www.w3.org/2001/XMLSchema','string','1','1','true'};
        private String[] mskey_type_info = new String[]{'mskey','http://www.w3.org/2001/XMLSchema','int','1','1','false'};
        private String[] relatiecode_type_info = new String[]{'relatiecode','http://www.w3.org/2001/XMLSchema','int','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://soapserver.jsm.marktselect.com','true'};
        private String[] field_order_type_info = new String[]{'errorCode','errorMessage','mskey','relatiecode'};
    }
    public class NewAccountResponse_element {
        public soapserver_MS_SFService.NewAccount[] NewAccountReturn;
        private String[] NewAccountReturn_type_info = new String[]{'NewAccountReturn','http://soapserver.jsm.marktselect.com','NewAccount','1','-1','false'};
        private String[] apex_schema_type_info = new String[]{'http://soapserver.jsm.marktselect.com','true'};
        private String[] field_order_type_info = new String[]{'NewAccountReturn'};
    }
    public class NewAccount_element {
        public String UserId;
        public String UserPw;
        public Integer Mskey;
        private String[] UserId_type_info = new String[]{'UserId','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] UserPw_type_info = new String[]{'UserPw','http://www.w3.org/2001/XMLSchema','string','1','1','false'};
        private String[] Mskey_type_info = new String[]{'Mskey','http://www.w3.org/2001/XMLSchema','int','1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://soapserver.jsm.marktselect.com','true'};
        private String[] field_order_type_info = new String[]{'UserId','UserPw','Mskey'};
    }
    public class SalesForceService_EnterpriceServicePort {
        public String endpoint_x = 'http://193.67.5.194/cgi-bin/jsmdirect?SFservice';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        private String[] ns_map_type_info = new String[]{'http://soapserver.jsm.marktselect.com', 'soapserver_MS_SFService'};
        public soapserver_MS_SFService.NewAccount[] NewAccount(String UserId,String UserPw,Integer Mskey) {
            soapserver_MS_SFService.NewAccount_element request_x = new soapserver_MS_SFService.NewAccount_element();
            soapserver_MS_SFService.NewAccountResponse_element response_x;
            request_x.UserId = UserId;
            request_x.UserPw = UserPw;
            request_x.Mskey = Mskey;
            Map<String, soapserver_MS_SFService.NewAccountResponse_element> response_map_x = new Map<String, soapserver_MS_SFService.NewAccountResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'NewAccount',
              'http://soapserver.jsm.marktselect.com',
              'NewAccount',
              'http://soapserver.jsm.marktselect.com',
              'NewAccountResponse',
              'soapserver_MS_SFService.NewAccountResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.NewAccountReturn;
        }
    }

 

 

THIS IS MY WRAPPER 

error=
Compile Error: Return value must be of type: String at line 6 column 9 

 

global class TestCallOut {
    WebService static  string LoadRlcode(string a, string b, integer mskey) {
        soapserver_MS_SFService.SalesForceService_EnterpriceServicePort soap =
        new soapserver_MS_SFService.SalesForceService_EnterpriceServicePort();
 
        return soap.NewAccount(a, b, mskey);
    }
}

Message Edited by Streepeye on 01-27-2009 01:39 AM

I am trying to implement the salesforce platform cookbook example to call an external webservice.

Following all the steps in the cookbook everything works fine except for the last part... the HTML part in the S-control.

I past the examplecode in the s-control and saved it ... then i created a web tab with that s-control.

 

Now, when i hit the tab i get a html/javascript/apex? error which say's "object expected".

If a test a little, the failing line is: var result= sforce.apex.execute("TestCallOut","quote",{symbol:"CRM"}); 

 

Has anybody an idea what i could miss/doing wrong?

 

 

 

THE WSDL APEX CLASS

 

NamewwwWebservicexNet  
Api Version14.0  
StatusActive  
Is ValidChecked  
BodyDownload Apex
//Generated by wsdl2apex

public class wwwWebservicexNet {
    public class GetQuote_element {
        public String symbol;
        private String[] symbol_type_info = new String[]{'symbol','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.webserviceX.NET/','true'};
        private String[] field_order_type_info = new String[]{'symbol'};
    }
    public class StockQuoteSoap {
        public String endpoint_x = 'http://www.webservicex.net/stockquote.asmx';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        private String[] ns_map_type_info = new String[]{'http://www.webserviceX.NET/', 'wwwWebservicexNet'};
        public String GetQuote(String symbol) {
            wwwWebservicexNet.GetQuote_element request_x = new wwwWebservicexNet.GetQuote_element();
            wwwWebservicexNet.GetQuoteResponse_element response_x;
            request_x.symbol = symbol;
            Map<String, wwwWebservicexNet.GetQuoteResponse_element> response_map_x = new Map<String, wwwWebservicexNet.GetQuoteResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://www.webserviceX.NET/GetQuote',
              'http://www.webserviceX.NET/',
              'GetQuote',
              'http://www.webserviceX.NET/',
              'GetQuoteResponse',
              'wwwWebservicexNet.GetQuoteResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.GetQuoteResult;
        }
    }
    public class GetQuoteResponse_element {
        public String GetQuoteResult;
        private String[] GetQuoteResult_type_info = new String[]{'GetQuoteResult','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.webserviceX.NET/','true'};
        private String[] field_order_type_info = new String[]{'GetQuoteResult'};
    }
}

 

THE APEXCLASS Wrapper

 

NameTestCallOut  
Api Version14.0  
StatusActive  
Is ValidChecked  
BodyDownload Apex
global class TestCallOut {
WebService static String quote(String symbol) {
wwwWebservicexNet.StockQuoteSoap stub =
new wwwWebservicexNet.StockQuoteSoap();
return stub.GetQuote(symbol);
}
}

 

 

The S-Control

 

LabelGenerate Stock QuoteFilename 
S-Control NameGenerate_Stock_Quote  
    
DescriptionGenerate Stock Quote
TypeHTML  
HTML Body<html>
<head>
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/10.0/connection.js"></script>
<script src="/soap/ajax/10.0/apex.js"></script>
<script>
sforce.debug.trace = true;
function stockQuote() {
var result= sforce.apex.execute("TestCallOut","quote",{symbol:"CRM"});
document.getElementById('userNameArea').innerHTML = 'Today's CRM Stockquote: '+result;
}
</script>

</head>
<body onload=stockQuote()>
<div id=userNameArea></div>

</body>
</html>
Prebuild In PageChecked

 

 

 

 

 

 

Message Edited by Streepeye on 01-26-2009 02:18 PM
Message Edited by Streepeye on 01-26-2009 02:20 PM
Message Edited by Streepeye on 01-26-2009 02:20 PM
Message Edited by Streepeye on 01-26-2009 02:22 PM

I would like to delete records using a external key.

But the delete operation from the APEX DATALOADER won't let me use the external key as key for deletion!

 

So, what is the way to delete records via an external key?

 

 

Message Edited by Streepeye on 03-31-2009 06:22 AM

Hi there,

I am trying to create a trigger on a custom object "VerwijderFnc__c" what deletes records in another custom object "Functionaris__c"

 

process is: insert a record into VerwijderFnc__c and get the Id from the Functionaris__c to delete those Functionaris__c record(s).

Sometimes i get more then 20 records as a result! and that is too much!

 

so i try to make this trigger bulksafe .... But i can't get ik to work for me !

This was 1e my code for the trigger: (NOT BULKSAFE)

 

trigger deleteFromFunctionaris on VerwijderFnc__c (before insert) {
     for(VerwijderFnc__c verwijdertabel: Trigger.new){
         for (Functionaris__c fs: [SELECT Id FROM Functionaris__c WHERE mskey__c = :verwijdertabel.MSkey__c]){
            //Delete all the Functionaris__c entries with given mskey__c
            delete fs;
         }
     }
}

 

then i tried something like: (BUT ALSO GIVES TOO MANYDML STATMENTS)

 

trigger deleteFromFunctionaris on VerwijderFnc__c (before insert) {

 

Map<String, VerwijderFnc__c> fncMap = new Map<String, VerwijderFnc__c>(); for (VerwijderFnc__c fnc : System.Trigger.new) {  if ((fnc.mskey__c != null) && (System.Trigger.isInsert || (fnc.mskey__c != System.Trigger.oldMap.get(fnc.Id).mskey__c))) {

fncMap.put(fnc.mskey__c, fnc);

}

}

 

for (Functionaris__c func : [SELECT Id FROM Functionaris__c WHERE mskey__c IN :fncMap.KeySet()]) { delete func;

}

}

 

 

 

!! Help !!

 

 

 

Message Edited by Streepeye on 03-31-2009 05:56 AM

I have a apexclass which calls an external webservice...

with the response i  am updating and inserting in the account object...

 

after everything has been updated and inserted i call the same webservice again with an other operation to tell the webservice that everything has been Done !

 

When i call the webservice with the other operation i get the "You have uncommitted work pending..." error.

 

Why...

How can i call the webservice after i inserted and updated....?

(i want to call the webservice after the updates and inserts because only then i know if everything went well!)

I have some apex-class code in a developers enviroment, works just fine!

 

I copy the code in a sandbox and de compilation fails on the line:

 

XMLDom responseXML = new XMLDom(res.getBody()); 

 

 

why?

 

public class SFService {

  //Future annotation to mark the method as async.
  // methods may call this class =callout=true
  @Future(callout=true)

   public static void SFservice(String id, String uid, String upw, Integer mskey ) {

   //construct an HTTP request
   HttpRequest req = new HttpRequest();
   req.setEndpoint('http://www.url.com/cgi-bin/jsmdirect?SFservice');
   req.setMethod('POST');
   req.setHeader('Content-Type', 'text/xml; charset=utf-8');

   // Create the soap message envelope 
   String soapMsg = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://soapserver.jsm.marktselect.com">'+
                       '<soapenv:Header/>'+
                           '<soapenv:Body>'+
                             '<soap:NewAccount>'+
                             '<soap:UserId>'+uid+'</soap:UserId>'+
                             '<soap:UserPw>'+upw+'</soap:UserPw>'+
                             '<soap:Mskey>'+mskey+'</soap:Mskey>'+
                          '</soap:NewAccount>'+
                       '</soapenv:Body>'+
                    '</soapenv:Envelope>';
                
   // set the soapbody to the message envelope                 
   req.setBody(soapMsg);




   //send the request
   Http http = new Http();
   HttpResponse res = http.send(req);
       
   //check the response
   if (res.getStatusCode() == 200) {
         XMLDom responseXML = new XMLDom(res.getBody());
         string rlcode = responseXML.getElementByTagName('relatiecode').nodeValue;
       

          //update account
          Account acc = new Account(Id=id);
          acc.AccountNumber = rlcode; 
          acc.Description = res.getStatus() ;
          update acc;
    } else {
          System.debug('Callout failed: ' + res);
          Account acc = new Account(Id=id);
          acc.Description = res.getStatus() ;
          update acc;

    } 
  }
}
Hi, I want to set the sessionid header element in the upsert operation! but i don't know how,... i am quit new with java. i get a header element but i dont know how to set the value which i just got from the login operation? see below "Add SOAP header" here is my generated java code: /** * SalesForceAgent_EnterpriceService.java * * This file was generated by LANSA Integrator SOAP Agent Wizard */ package com.marktselect.service.soap ; public class SalesForceAgent_EnterpriceService implements com.lansa.jsm.service.SOAPAgentHandler { /* Operation - login */ public final void setOperation_LOGIN () { } /* Operation Request - login */ public final void prepareRequest_LOGIN ( com.lansa.jsm.service.SOAPAgentRequest request ) throws Exception { request.prepareParameter ( "USERNAME", java.lang.String.class, false, false ) ; request.prepareParameter ( "PASSWORD", java.lang.String.class, false, false ) ; } /* Operation Parameter - login */ public final void setParameter_LOGIN_USERNAME ( com.lansa.jsm.service.SOAPAgentParameter parameter, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { parameter.setEntity ( bind.getFieldValue ( "MSLOGUSR" ), null, null ) ; } /* Operation Parameter - login */ public final void setParameter_LOGIN_PASSWORD ( com.lansa.jsm.service.SOAPAgentParameter parameter, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { parameter.setEntity ( bind.getFieldValue ( "MSLOGPWD" ), null, null ) ; } /* Operation Response - login */ public final void prepareResponse_LOGIN ( com.lansa.jsm.service.SOAPAgentResponse response ) throws Exception { response.prepareFragment ( new String[] { "LOGIN" }, com.sforce.soap.enterprise.LoginResult.class, false, true, null ) ; response.prepareFragment ( new String[] { "LOGIN", "USERINFO" }, com.sforce.soap.enterprise.GetUserInfoResult.class, false, true, "getUserInfo" ) ; } /* Operation Fragment - login */ public final void getFragment_LOGIN_LOGIN ( com.lansa.jsm.service.SOAPAgentResponseFragment fragment, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { bind.setFieldValue ( "URLSERVER", fragment.getEntity ( "metadataServerUrl", null ) ) ; bind.setFieldValue ( "PWEXPIRED", fragment.getEntity ( "passwordExpired", null ) ) ; bind.setFieldValue ( "SANDBOX", fragment.getEntity ( "sandbox", null ) ) ; bind.setFieldValue ( "SERVERURL", fragment.getEntity ( "serverUrl", null ) ) ; bind.setFieldValue ( "SESSIONID", fragment.getEntity ( "sessionId", null ) ) ; bind.setFieldValue ( "USERID", fragment.getEntity ( "userId", null ) ) ; } /* Operation Fragment - login */ public final void getFragment_LOGIN_USERINFO ( com.lansa.jsm.service.SOAPAgentResponseFragment fragment, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { bind.setFieldValue ( "ACCMODE", fragment.getEntity ( "accessibilityMode", null ) ) ; bind.setFieldValue ( "CURSYMBOL", fragment.getEntity ( "currencySymbol", null ) ) ; bind.setFieldValue ( "ORGISOCOD", fragment.getEntity ( "orgDefaultCurrencyIsoCode", null ) ) ; bind.setFieldValue ( "PERSACC", fragment.getEntity ( "orgHasPersonAccounts", null ) ) ; bind.setFieldValue ( "ORGID", fragment.getEntity ( "organizationId", null ) ) ; bind.setFieldValue ( "ORGMLTCUR", fragment.getEntity ( "organizationMultiCurrency", null ) ) ; bind.setFieldValue ( "MSBEDRNM", fragment.getEntity ( "organizationName", null ) ) ; bind.setFieldValue ( "MSPROFILE", fragment.getEntity ( "profileId", null ) ) ; bind.setFieldValue ( "ROLEID", fragment.getEntity ( "roleId", null ) ) ; bind.setFieldValue ( "DEFCURCOD", fragment.getEntity ( "userDefaultCurrencyIsoCode", null ) ) ; bind.setFieldValue ( "MSEMAIL", fragment.getEntity ( "userEmail", null ) ) ; bind.setFieldValue ( "MSFULLNM", fragment.getEntity ( "userFullName", null ) ) ; bind.setFieldValue ( "MSUSRID", fragment.getEntity ( "userId", null ) ) ; bind.setFieldValue ( "USERLANG", fragment.getEntity ( "userLanguage", null ) ) ; bind.setFieldValue ( "USERLOCAL", fragment.getEntity ( "userLocale", null ) ) ; bind.setFieldValue ( "USRNAME", fragment.getEntity ( "userName", null ) ) ; bind.setFieldValue ( "TIMEZONE", fragment.getEntity ( "userTimeZone", null ) ) ; bind.setFieldValue ( "MSUSRTYPE", fragment.getEntity ( "userType", null ) ) ; bind.setFieldValue ( "UISKIN", fragment.getEntity ( "userUiSkin", null ) ) ; } /* Operation Return - login */ public final void getReturnParameter_LOGIN ( com.lansa.jsm.service.SOAPAgentResponse response, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { } /* Operation Call - login */ public final com.lansa.jsm.service.SOAPAgentResponse callOperation_LOGIN ( com.lansa.jsm.service.SOAPAgentRequest request, String user, String password, String url ) throws Exception { com.sforce.soap.enterprise.SforceServiceLocator locator = new com.sforce.soap.enterprise.SforceServiceLocator () ; String endPoint = locator.getSoapAddress () ; if ( url != null ) { endPoint = url ; } com.sforce.soap.enterprise.SoapBindingStub stub = (com.sforce.soap.enterprise.SoapBindingStub)locator.getSoap ( new java.net.URL ( endPoint ) ) ; if ( user != null && password != null ) { stub.setUsername ( user ) ; stub.setPassword ( password ) ; } /* Add SOAP header */ org.apache.axis.message.SOAPHeaderElement elementHead = new org.apache.axis.message.SOAPHeaderElement ("", "SessionHeader"); javax.xml.soap.SOAPElement elementsessionId = elementHead.addChildElement ( "sessionId" ) ; elementsessionId.addTextNode ( "HOW DO I GET THE SESSIONID IN HERE?" ); stub.setHeader ( elementHead ) ; /* End SOAP header */ request.traceStub ( stub ) ; return new com.lansa.jsm.service.SOAPAgentResponse ( stub.login( request.getParameterValueString ( "USERNAME" ), request.getParameterValueString ( "PASSWORD" ) ) ) ; } /* Operation - upsert */ public final void setOperation_UPSERT () { } /* Operation Request - upsert */ public final void prepareRequest_UPSERT ( com.lansa.jsm.service.SOAPAgentRequest request ) throws Exception { request.prepareParameter ( "EXTERNALIDFIELDNAME", java.lang.String.class, false, false ) ; request.prepareParameter ( "SOBJECTS", com.sforce.soap.enterprise.sobject.SObject.class, true, true ) ; request.prepareFragment ( "SOBJECTS", new String[] { "UPSERTOBJ" }, com.sforce.soap.enterprise.sobject.SObject.class, true, true, null ) ; request.prepareList ( "SOBJECTS", new String[] { "UPSERTOBJ", "OBJNAME" }, java.lang.String.class, true, false, "setFieldsToNull" ) ; } /* Operation Parameter - upsert */ public final void setParameter_UPSERT_EXTERNALIDFIELDNAME ( com.lansa.jsm.service.SOAPAgentParameter parameter, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { parameter.setEntity ( bind.getFieldValue ( "EXTFLDNM" ), null, null ) ; } /* Operation Parameter - upsert */ public final void setParameter_UPSERT_SOBJECTS ( com.lansa.jsm.service.SOAPAgentParameter parameter, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { } /* Operation Fragment - upsert */ public final void setFragment_UPSERT_SOBJECTS_UPSERTOBJ ( com.lansa.jsm.service.SOAPAgentRequestFragment fragment, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { fragment.setEntity ( "id", bind.getFieldValue ( "SFIDSTR" ), null, null ) ; } public final com.lansa.jsm.service.SOAPAgentList setList_UPSERT_UPSERTOBJ_OBJNAME () throws Exception { return new com.lansa.jsm.service.SOAPAgentList ( new String[] { "OBJELEM" }, new String[] { "entry" }, new com.lansa.jsm.service.SOAPEntityFormat[] { null } ) ; } /* Operation Response - upsert */ public final void prepareResponse_UPSERT ( com.lansa.jsm.service.SOAPAgentResponse response ) throws Exception { response.prepareFragment ( new String[] { "UPSERTRESULT" }, com.sforce.soap.enterprise.UpsertResult.class, true, true, null ) ; response.prepareFragment ( new String[] { "UPSERTRESULT", "ERRORS" }, com.sforce.soap.enterprise.Error.class, true, true, "getErrors" ) ; response.prepareList ( new String[] { "UPSERTRESULT", "ERRORS", "OBJRETLST" }, java.lang.String.class, true, false, "getFields" ) ; } /* Operation Fragment - upsert */ public final void getFragment_UPSERT_UPSERTRESULT ( com.lansa.jsm.service.SOAPAgentResponseFragment fragment, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { bind.setFieldValue ( "ISCREATED", fragment.getEntity ( "created", null ) ) ; bind.setFieldValue ( "SFRETID", fragment.getEntity ( "id", null ) ) ; bind.setFieldValue ( "ISSUCCES", fragment.getEntity ( "success", null ) ) ; } /* Operation Fragment - upsert */ public final void getFragment_UPSERT_ERRORS ( com.lansa.jsm.service.SOAPAgentResponseFragment fragment, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { bind.setFieldValue ( "MSERRMSG", fragment.getEntity ( "message", null ) ) ; bind.setFieldValue ( "MSERRCODS", fragment.getEntity ( "statusCode", null ) ) ; } public final com.lansa.jsm.service.SOAPAgentList getList_UPSERT_ERRORS_OBJRETLST () throws Exception { return new com.lansa.jsm.service.SOAPAgentList ( new String[] { "OBJELEM" }, new String[] { "entry" }, new com.lansa.jsm.service.SOAPEntityFormat[] { null } ) ; } /* Operation Return - upsert */ public final void getReturnParameter_UPSERT ( com.lansa.jsm.service.SOAPAgentResponse response, com.lansa.jsm.service.SOAPAgentBind bind ) throws Exception { } /* Operation Call - upsert */ public final com.lansa.jsm.service.SOAPAgentResponse callOperation_UPSERT ( com.lansa.jsm.service.SOAPAgentRequest request, String user, String password, String url ) throws Exception { com.sforce.soap.enterprise.SforceServiceLocator locator = new com.sforce.soap.enterprise.SforceServiceLocator () ; String endPoint = locator.getSoapAddress () ; if ( url != null ) { endPoint = url ; } com.sforce.soap.enterprise.SoapBindingStub stub = (com.sforce.soap.enterprise.SoapBindingStub)locator.getSoap ( new java.net.URL ( endPoint ) ) ; if ( user != null && password != null ) { stub.setUsername ( user ) ; stub.setPassword ( password ) ; } /* Add SOAP header */ org.apache.axis.message.SOAPHeaderElement elementHead = new org.apache.axis.message.SOAPHeaderElement ("", "SessionHeader"); javax.xml.soap.SOAPElement elementsessionId = elementHead.addChildElement ( "sessionId" ) ; elementsessionId.addTextNode ( "HOW DO I GET THE SESSIONID IN HERE?" ); stub.setHeader ( elementHead ) ; /* End SOAP header */ request.traceStub ( stub ) ; return new com.lansa.jsm.service.SOAPAgentResponse ( stub.upsert( request.getParameterValueString ( "EXTERNALIDFIELDNAME" ), (com.sforce.soap.enterprise.sobject.SObject[])request.getParameterValueObject ( "SOBJECTS" ) ) ) ; } } this is the generated reguest: - - - HOW DO I GET THE SESSIONID IN HERE? - - mskey__c - 34 11111

i try to usert something with de enterprise.wsdl

 

i am getting the following error when i request the UPSERT operation

 

Does anybody knows where this is refering to / what goes wrong or what doe i have to give a value?

 

 THE REQUEST

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com" xmlns:urn1="urn:sobject.enterprise.soap.sforce.com">
   <soapenv:Header>
      <urn:EmailHeader>
         <urn:triggerAutoResponseEmail></urn:triggerAutoResponseEmail>
         <urn:triggerOtherEmail></urn:triggerOtherEmail>
         <urn:triggerUserEmail></urn:triggerUserEmail>
      </urn:EmailHeader>
      <urn:DebuggingHeader>
         <urn:debugLevel></urn:debugLevel>
      </urn:DebuggingHeader>
      <urn:MruHeader>
         <urn:updateMru></urn:updateMru>
      </urn:MruHeader>
      <urn:AssignmentRuleHeader>
         <urn:assignmentRuleId></urn:assignmentRuleId>
         <urn:useDefaultRule></urn:useDefaultRule>
      </urn:AssignmentRuleHeader>
      <urn:SessionHeader>
         <urn:sessionId>fp6KrNsQwVjKNplTnn4CN2xd</urn:sessionId>
      </urn:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <urn:upsert>
        <urn:externalIDFieldName>mskey__c</urn:externalIDFieldName>
        <urn:sObjects xsi:type="NewRBScodes__c">
           <mskey__c>1</mskey__c>
           <Name>000002</Name>
           <rlcode__c>340</rlcode__c>
        </urn:sObjects>
      </urn:upsert>
   </soapenv:Body>
</soapenv:Envelope> 

 

 

 

THE RESPONSE

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>soapenv:Client</faultcode>
         <faultstring>'' is not a valid value for the enum 'LogType'</faultstring>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>

I am trying to implement the salesforce platform cookbook example to call an external webservice.

Following all the steps in the cookbook everything works fine except for the last part... the HTML part in the S-control.

I past the examplecode in the s-control and saved it ... then i created a web tab with that s-control.

 

Now, when i hit the tab i get a html/javascript/apex? error which say's "object expected".

If a test a little, the failing line is: var result= sforce.apex.execute("TestCallOut","quote",{symbol:"CRM"}); 

 

Has anybody an idea what i could miss/doing wrong?

 

 

 

THE WSDL APEX CLASS

 

NamewwwWebservicexNet  
Api Version14.0  
StatusActive  
Is ValidChecked  
BodyDownload Apex
//Generated by wsdl2apex

public class wwwWebservicexNet {
    public class GetQuote_element {
        public String symbol;
        private String[] symbol_type_info = new String[]{'symbol','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.webserviceX.NET/','true'};
        private String[] field_order_type_info = new String[]{'symbol'};
    }
    public class StockQuoteSoap {
        public String endpoint_x = 'http://www.webservicex.net/stockquote.asmx';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        private String[] ns_map_type_info = new String[]{'http://www.webserviceX.NET/', 'wwwWebservicexNet'};
        public String GetQuote(String symbol) {
            wwwWebservicexNet.GetQuote_element request_x = new wwwWebservicexNet.GetQuote_element();
            wwwWebservicexNet.GetQuoteResponse_element response_x;
            request_x.symbol = symbol;
            Map<String, wwwWebservicexNet.GetQuoteResponse_element> response_map_x = new Map<String, wwwWebservicexNet.GetQuoteResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://www.webserviceX.NET/GetQuote',
              'http://www.webserviceX.NET/',
              'GetQuote',
              'http://www.webserviceX.NET/',
              'GetQuoteResponse',
              'wwwWebservicexNet.GetQuoteResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.GetQuoteResult;
        }
    }
    public class GetQuoteResponse_element {
        public String GetQuoteResult;
        private String[] GetQuoteResult_type_info = new String[]{'GetQuoteResult','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.webserviceX.NET/','true'};
        private String[] field_order_type_info = new String[]{'GetQuoteResult'};
    }
}

 

THE APEXCLASS Wrapper

 

NameTestCallOut  
Api Version14.0  
StatusActive  
Is ValidChecked  
BodyDownload Apex
global class TestCallOut {
WebService static String quote(String symbol) {
wwwWebservicexNet.StockQuoteSoap stub =
new wwwWebservicexNet.StockQuoteSoap();
return stub.GetQuote(symbol);
}
}

 

 

The S-Control

 

LabelGenerate Stock QuoteFilename 
S-Control NameGenerate_Stock_Quote  
    
DescriptionGenerate Stock Quote
TypeHTML  
HTML Body<html>
<head>
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/10.0/connection.js"></script>
<script src="/soap/ajax/10.0/apex.js"></script>
<script>
sforce.debug.trace = true;
function stockQuote() {
var result= sforce.apex.execute("TestCallOut","quote",{symbol:"CRM"});
document.getElementById('userNameArea').innerHTML = 'Today's CRM Stockquote: '+result;
}
</script>

</head>
<body onload=stockQuote()>
<div id=userNameArea></div>

</body>
</html>
Prebuild In PageChecked

 

 

 

 

 

 

Message Edited by Streepeye on 01-26-2009 02:18 PM
Message Edited by Streepeye on 01-26-2009 02:20 PM
Message Edited by Streepeye on 01-26-2009 02:20 PM
Message Edited by Streepeye on 01-26-2009 02:22 PM