Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

Accessing apex webservice/SOAP method from PHP

General Tech Bugs & Fixes
Max. 2000 characters
Replies

usr_profile.png
Brian Burl

User

( 7 months ago )

 

I am trying to call a SF method from a remote PHP script. I am using github.com/developerforce/Force.com-Toolkit-for-PHP.

Method has been set as a webservice :

global class groupCamp {
    webservice static void method() {
        // some HTTP requests & mails here
    }
}

PHP code :

ini_set("soap.wsdl_cache_enabled", "0");
require_once ('soapclient/SforceEnterpriseClient.php');

// connection
$mySforceConnection = new SforceEnterpriseClient();
$mySforceConnection->createConnection("soapclient/enterprise.wsdl.xml");
// question 1
$mySforceConnection->setEndPoint("https://login.salesforce.com/services/Soap/c/36.0");

define("USERNAME", …);
define("PASSWORD", …);
define("SECURITY_TOKEN", …);

$login = $mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);
$client = new SoapClient("groupCamp.xml");
$header = new SoapHeader("http://soap.sforce.com/schemas/class/groupCamp", "SessionHeader",
  ["sessionId" => $mySforceConnection->getSessionId()]);
$client->__setSoapHeaders([$header]);

// question 2
$client->__setLocation(get_object_vars($login)['serverUrl']);


try {
    $client->method();
} catch (Exception $e) {
    fwrite(fopen("SalesforceToGroupcamp.log", 'a'), date('Y-m-d H:i:s')." : ".$e->getMessage()." : ".$e->getLine()."\n".$e->getTraceAsString());
}

I get the error :

No operation available for request {http://soap.sforce.com/schemas/class/groupCamp}mymethod

Question 1 : What am I supposed to put here : same version number as API I guess ? And why /u/ or /c/ ?

Question 2 : is this how I am supposed to define location ? Or is this with setEndpoint, or in the header ?

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif