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
SoleesSolees 

Does anyone has an example of PHP Webservice and Salesforce callout?

Hi friends, im trying to make an PHP Webservice using NuSoap and everything its just fine when importing the WSDL, but when i create de Apex Page to call that code, there is no response.
Does anyone have a PHP NuSoap "HelloWorld" example and the Salesforce Apex code to call it?
Thank you very much.
 
My PHP Code:

<?php

// Pull in the NuSOAP code

require_once("libs/nusoap.php");

// creat a new web server and configure wsdl

$ns="http://www.mypage.com";

$server = new soap_server();

$server->configureWSDL('fooMethod', $ns, '', 'document');

$server->xml_encoding = "utf-8";

$server->soap_defencoding = "utf-8";

$server->wsdl->schemaTargetNamespace=$ns;

// server return literal xml

$server->methodreturnisliteralxml = true;

 

function fooMethod($name) {

$x="<fooMethodResponse>hello $name!</fooMethodResponse>";

return $x;

}

$server->register(

'fooMethod',// method name

array('name' => 'xsd:string'), // input parameters

array('result' => 'xsd:string'), // output parameters

$ns, // namespace

false, // soapaction

'document', // style

'literal', // use

'greating some body' // documentation );

 

// Use the request to (try to) invoke the service

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';

$server->service($HTTP_RAW_POST_DATA);

?>

mediaprojectsmediaprojects

Hi Solees,

 

I recommend you to look into the Salesforce module for Zend Framework: http://framework.zend.com/wiki/display/ZFPROP/Zend_Service_Salesforce+-+Barefoot+Solutions

 

There are some bugs. But you can fix them easily. I use this library for my Kohana-based php application.

 

Good luck,

Michael

SoleesSolees

Thanks Michael for that Code, its great !! but i still cant find the way to connect Salesforce to a PHP Webservice with NuSOAP, have you ever tried this?

mediaprojectsmediaprojects

I always had problems with NuSOAP before. Besides, I find it much more convinient to use Zend-related library as it removes necessity of dealing with the low-level request construction you have to deal with using NuSOAP.

SoleesSolees

Ok, let me open up my question then :D

 

how would you connect Salesforce to a PHP/MySql Server and extract inside of Salesforce using Apex Classes information from any MySql table?

 

My first try was NuSOAP to create the WebService in PHP and connect it to Salesforce, but i can try some other ways to create WebServices in PHP Document/Literal type that Salesforce can convert (the WSDL) into Apex Class.

 

Hope there is other solutions.

 

Cheers

mediaprojectsmediaprojects

I did not dive into that level. I use Zend/Salesforce library which has almost everything you need to access and manipulate the Salesforce objects. Extracting from SF can be done via SOQL using the Zend/SF lib. If you need to populate a certain object with a data you can also do that with that lib. Fixing the bugs in that lib would take 15 mins of your time.

SoleesSolees

Zend its a great PHP Library to access and manipulate Salesforce, but i still cant go out of Salesforce with Apex Code and grab some info talking to a PHP WebService, need help there.