How to consume web service?

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
Boca
User
Posts: 30

How to consume web service?

Post by Boca »

Hello guys,
How to consume web service in PHPMaker to integrate with another application?
thankful


mobhar
User
Posts: 11703

Post by mobhar »

Make sure your web server supports to access the web service.

For example, I am using Wampserver, then I can simply enable "php_soap" PHP extension from my web server side, and then I can simply expose the "SoapClient" object to consume the web service:

try {        
	$wsdl = "<the_url_to_your_wsdl>"; // adjust it to your WSDL URL
	$client = new SoapClient($wsdl); // create a new SoapClient object
	$response = $client->getSomething(array('ABC' => $rsnew["ABC"])); // adjust "getSomething" with your web service method, adjust also the param of it
	//  your code goes here to check the response output
	//  and so forth ...
	//var_dump($response);
} catch (Exception $e) {  // catch the error below
	$this->setFailureMessage("Failed to access the web service. <br>Error message: ".$e->getMessage());
}

Boca
User
Posts: 30

Post by Boca »

Thank you, I'll apply your suggestion.


ameisfine
User
Posts: 74

Post by ameisfine »

mobhar wrote:

try {
$wsdl = "<the_url_to_your_wsdl>"; // adjust it to your WSDL URL
$client = new SoapClient($wsdl); // create a new SoapClient object
$response = $client->getSomething(array('ABC' => $rsnew["ABC"]));
} catch (Exception $e) { // catch the error below
$this->setFailureMessage("Failed to access the web service. <br>Error message: ".$e->getMessage());
}

Hi, where to put this code in Server Events ? in which Function?


mobhar
User
Posts: 11703

Post by mobhar »

It actually depends on your business-logic. For example, if you want to execute that code after a new record is inserted, then simply put it in Row_Inserted server event.


ameisfine
User
Posts: 74

Post by ameisfine »

I want to check a record from database with a soap xml provided by other company. I think i am gonna make an additional button "Check this profile" (each row) in Table-Spesific>List Page>ListOptions_Rendered
But then i am still confused how is the syntax to do that? Thanks.


mobhar
User
Posts: 11703

Post by mobhar »

You'd better use Page_Load and Row_CustomAction for such case. Just call a Custom File that receives Get() param, and return your desired value from that web service.


Post Reply