Download presentation
Presentation is loading. Please wait.
Published byMaximilian King Modified over 9 years ago
1
Sforce & Open Source: Perl and PHP Presented by Byrne Reese Director, Product Management – Grand Central Communications Lead Developer – SOAP::Lite Project
2
Agenda Introduction to SOAP::Lite and Pear SOAP How to call login, query, and queryMore. Implement queryMore in PERL Implement abstraction layer in PHP Sample application in two languages
3
Perl: Why SOAP::Lite? Pro’s Simple API Control over XML PERL’s utility goes way beyond the Web Ubiquity of Perl Excellent developer support, and 3 rd party tool set SOAP over HTTP, FTP, Jabber, and more Con’s Poor WSDL Support (so far…)
4
Perl: Salesforce Module What is included: –README.txt and INSTALL.txt –lib/Salesforce.pm –examples/salesforce.cgi –Unit test framework
5
Perl: Installation Install SOAP::Lite > perl –MCPAN –e ‘install SOAP::Lite’ Download Salesforce-0.50.tar.gz from http://majordojo.com/salesforce Unpack Salesforce-0.50.tar.gz Run the standard: > cd Salesforce-0.50 > perl Makefile.PL > make > make test > make install
6
Perl: login Session ID is automatically persisted for subsequent calls #!/usr/bin/perl use Salesforce; my $service = new Salesforce::SforceService; my $port = $service->get_port_binding('Soap'); $port->login('username' => ‘byrne@sforce.com’, 'password' => ‘mypassword’);
7
Perl: query Perform a Query… #!/usr/bin/perl use Salesforce;... my $query_str = "select $COLUMNS from $DATATYPE"; $result = $port->query('query' => $query_str, 'limit' => 10);
8
Perl: query (cont.) Parse the results #!/usr/bin/perl use Salesforce;... $result = $port->query('query'=>‘select FirstName,LastName from lead’, 'limit' => 10); foreach my $elem ($result->valueof('//queryResponse/result/records')) { printf "%s, %s\n", $elem->{LastName},$elem->{FirstName}; }
9
Perl: queryMore Let’s implement queryMore
10
Perl: Additional Resources SOAP::Lite Project Homepage http://www.soaplite.com SOAP::Lite Solutions http://majordojo.com/soaplite/ Salesforce Perl Module Home http://majordojo.com/salesforce/ O’Reilly’s Programming Web Services with Perl, Randy J. Ray and Paul Kulchenko
11
Perl: The Future of SOAP::Lite Full support for WSDL
12
PHP: Why PHP and Pear SOAP? Pro’s PHP is tailored for the Web WSDL Support Late binding Con’s Web only – well, sort of.
13
PHP: SalesforceClientPHP What is included: –login.php, list.php, and more –WebService_SforceService_Soap.php –SalesforceClient.php –README.txt
14
PHP: Installation Prerequisites: –Pear SOAP –PHP 4.3.4 or greater (compiled with –with-zlib flag) Install required Pear Modules: > pear install
15
PHP: Installation (cont.) Download SalesforceClientPHP.tar.gz from http://majordojo.com/salesforce Unpack SalesforceClientPHP.tar.gz Generate Stub Code: > php /usr/local/lib/php/SOAP/tools/genproxy.php
16
PHP: Extend Base Class For most projects, the generated stub code is enough Salesforce, however, requires SOAP Headers to be set Create a new class SalesforceClient that extends the base class created by genproxy.php
17
PHP: SalesforceClient <?php require_once("WebService_SforceService_Soap.php"); class SalesforceClient extends WebService_SforceService_Soap {... } ?>
18
PHP: Constructor class SalesforceClient extends WebService_SforceService_Soap { function SalesforceClient($sessionId="") { $this->WebService_SforceService_Soap(); if (isset($sessionId) && $sessionId != "") { $header = new SOAP_Header('{urn:partner.soap.sforce.com}SessionHeader', NULL, array('sessionId' => $sessionId), 0); $this->addHeader($header); }
19
PHP: query class SalesforceClient extends WebService_SforceService_Soap {... function query($query,$limit=10) { $header = new SOAP_Header( '{urn:partner.soap.sforce.com}QueryOptions', NULL, array('batchSize' => $limit), 0); $this->addHeader($header); return parent::query($query); }
20
PHP: Additional Resources PHP Project Homepage http://www.php.net Pear Network http://pear.php.net Pear SOAP Home http://pear.php.net/package/SOAP
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.