You need to sign in to do that
Don't have an account?

Got error "Fatal error: Uncaught SoapFault exception"
Hi.
I'm trying to access apex clases via PHP. But got error -
Fatal error: Uncaught SoapFault exception: [soapenv:Client] Element {}item invalid at this location in /home/oleg/sites/site.php:30 Stack trace: #0 [internal function]: SoapClient->__call('Test', Array) #1 /home/oleg/sites/site.php(30): SoapClient->Test() #2 {main} thrown in /home/oleg/sites/site.php on line 30
Apex Code:
global class Test1 {
webservice static String Test2() {
return 'Got it';
}
PHP Code:
<html>
<head>
<title> PHP SalesForce Test </title>
</head>
<body>
<?php
ini_set("soap.wsdl_cache_enabled", "0");
require_once('salesforceAPI/SforcePartnerClient.php');
require_once('salesforceAPI/SforceHeaderOptions.php');
$sfdc = new SforcePartnerClient();
$SoapClient = $sfdc->createConnection('salesforceAPI/wsdl.xml');
$loginResult = false;
$loginResult = $sfdc->login('login@login', 'password' . 'token');
$parsedURL = parse_url($sfdc->getLocation());
define ("_SFDC_SERVER_", substr($parsedURL['host'],0,strpos($parsedURL['host'], '.')));
define ("_WS_NAME_", 'Test1');
define ("_WS_WSDL_", _WS_NAME_ . '.xml');
define ("_WS_ENDPOINT_", 'https://' . _SFDC_SERVER_ . '.salesforce.com/services/wsdl/class/' . _WS_NAME_);
define ("_WS_NAMESPACE_", 'http://soap.sforce.com/schemas/class/' . _WS_NAME_);
$client = new SoapClient(_WS_WSDL_);
$sforce_header = new SoapHeader(_WS_NAMESPACE_, "SessionHeader", array("sessionId" => $sfdc->getSessionId()));
$client->__setSoapHeaders(array($sforce_header));
$responce = $client->Test2();
echo "Message is " . $response;
?>
</body>
</html>
Thank you.
I put Test1.xml in the root directory of webserver.
( Test1.xml is a WSDL file from salesforce )
We are seeing the same error here. How did you resolve this?
Thank You,
Adam Daw
Cheers!
I solved this problem for myself when found out I need to add managed package prefix in a couple of places:
define ("_WS_ENDPOINT_", 'https://' . _SFDC_SERVER_ . '.salesforce.com/services/wsdl/class/lod3/' . _WS_NAME_);define ("_WS_NAMESPACE_", 'http://soap.sforce.com/schemas/class/lod3/' . _WS_NAME_);
lod3 is our namespace prefix - with it everything worked like a charm.