function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rchoi21rchoi21 

PHP stand-alone Partner client based on NuSOAP

Hi,

I've written a small sforce Partner WSDL PHP library based on the NuSOAP SOAP Toolkit. It obviates the need for PHP 5 and PEAR. All you need is the salesforce.php and nusoap.php files, both of which are included in the attached zip file. Download the zip from sourceforge at:

http://osdn.dl.sourceforge.net/sourceforge/sforce/php.sforce.nusoap.20051012.zip

Most of the API methods have been implemented; feel free to recommend more. The goal of this library was to make the basic operations -- create, update, delete, query, search -- easy to do. A lot of the response objects are still native PHP types. However, I've made a point of declaring a sObject class and returning it wherever possible.

I've also included an example php file and the original nusoap.php file, so you can see what modifications I've made.

Please send comments and feedback to rchoi21_AT_hotmail.com.

Thanks!

Ryan Choi
rchoi21_AT_hotmail.com

(Sorry for the re-post. Wouldn't let me edit the URL to point to sourceforge.)
colingcoling
Having used NuSoap before, I tried your example, and it worked for me.

However, I would like to emulate the process provided by php-client by being able to submit requests that provide a sessionId (and endpoint), instead of logging in first. I am trying to embed my application/product within SF, accessible via its own web tab.

I have started with the following. Variables $ah_sess_id and $sf_endpoint come from web tab parameters.

$COLUMNS = 'Id,FirstName,LastName,Email';
$DATATYPE = 'Contact';
$LIMIT = 200;
$query_str = "select $COLUMNS from $DATATYPE";

$wsdl_url = "http://my/url/for/sforce_partner.wsdl";
$sfdc = new salesforce($wsdl_url);
$element = new soapval('sessionId', null, $ah_sess_id);
$element = array($element);
$sfdc->setHeader('SessionHeader', $element);

if (isset($QUERY_LOCATOR)) {
$result = $sfdc->queryMore($QUERY_LOCATOR,$LIMIT);
} else {
$result = $sfdc->query($query_str,$LIMIT);
}

The above gives me error "UNKNOWN_EXCEPTION: Destination URL not reset. The URL returned from login must be set in the SforceService"

How do I set the endpoint URL?

Colin Goldberg
runawaydogrunawaydog
can this do convert leads?
rchoi21rchoi21
implemented convertlead method. tell me what you think.

http://sourceforge.net/project/showfiles.php?group_id=96634&package_id=166314

Message Edited by rchoi21 on 10-27-2005 01:58 PM

rchoi21rchoi21
i updated the package to have the methods setSession() and setURL(). give it a try and tell me what you think.

http://sourceforge.net/project/showfiles.php?group_id=96634&package_id=166314

Message Edited by rchoi21 on 10-27-2005 01:58 PM

hemmhemm
I am getting setup with your tool, but I am getting an error at runtime when working locally. I installed XAMPP (http://www.apachefriends.org/en/index.html) to install Apache, PHP, Perl, etc. on my Windows machine. I have Apache2 and PHP 5.0.5. Are there any other requirements needed by your code? I am getting the following error.

Fatal error: Cannot redeclare class soapclient in C:\Program Files\xampp\htdocs\sforcePHP\nusoap.php on line 7276

The code DOES work when I upload the PHP files to my web host. However, I'd like to be able to work locally rather than keep uploading the files everytime I need to test.

Any ideas?
hemmhemm


hemm wrote:
I am getting setup with your tool, but I am getting an error at runtime when working locally. I installed XAMPP (http://www.apachefriends.org/en/index.html) to install Apache, PHP, Perl, etc. on my Windows machine. I have Apache2 and PHP 5.0.5. Are there any other requirements needed by your code? I am getting the following error.

Fatal error: Cannot redeclare class soapclient in C:\Program Files\xampp\htdocs\sforcePHP\nusoap.php on line 7276

The code DOES work when I upload the PHP files to my web host. However, I'd like to be able to work locally rather than keep uploading the files everytime I need to test.

Any ideas?




I didn't resolve my issue, but I was able to get the connector working when I used PHP 4.3.4. PHP 5.0.5 did not work and I am not exactly sure why that is. I believe that PHP 5.0.5 replaced NUSOAP with another SOAP package and the object name "soapclient" still exists.
SynchroSynchro
You're right on this. PHP 5 has built-in SOAP support (often referred to as ext/soap) and it does use the SOAPClient class name, so it clashes with NuSOAP. On the whole NuSOAP is considered obsolete, and the PHP5 soap client gives much better performance. The new soap extension has been undergoing changes and fixes, so I suggest you use the latest PHP, 5.0.5 or 5.1.0 (which should be final in the next week or so).
CarteBlancheCarteBlanche
Hi guys, looking for help - I am using PHP 5.2.5 with nusoap

I have a custom object called "Persons" (singular, Person) that I would like to update.  The code I am running is:

$id = $_POST['Id'];

$person1 = new sObject('Person__c',
    $id,
    array(
       'Address1__c' => 'new address1',
       'Address2__c' => 'new address2'
    ),
       array('State__c, 'Zip__c')
    );

$updateResult = $sfdc->update($person1);



And I am getting the error

"Id not specified in an update call [statusCode] => MISSING_ARGUMENT) [id]"

Can you tell me what I am doing wrong?

Thanks
ChuckWebGuyChuckWebGuy

Is it possible that the NuSOAP update method is no longer compatible with the sfapi?  The following seems to no longer work for me:

 

$contact1 = new sObject('lead',
            $id,
            array(
                'Description' => 'My test',
                        'Email' => 'cwyatt123@blahblahblah.com',
                                                $whitepaperval,
                                                        $interactivetour
            ),
                array('Description', 'Email', 'white_paper__c', 'interactive_tour__c'           );
    $updateResult = $sfdc->update($contact1);
    print_r("\nupdate one: \n\n");
    print_r($updateResult);
 

SuperfellSuperfell
the xml structure of the update api call hasn't changed in a long time, in what why is it not working? can you get a capture of your actual http/xml request ?