Page 1 of 1

How to consume web service?

Posted: Wed Dec 13, 2017 7:43 pm
by Boca

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


Re: How to consume web service

Posted: Wed Dec 13, 2017 9:18 pm
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());
}

Re: How to consume web service

Posted: Mon Jan 15, 2018 9:59 pm
by Boca

Thank you, I'll apply your suggestion.


Re: How to consume web service

Posted: Mon Jan 11, 2021 12:16 pm
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?


Re: How to consume web service

Posted: Mon Jan 11, 2021 12:47 pm
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.


Re: How to consume web service

Posted: Mon Jan 11, 2021 4:16 pm
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.


Re: How to consume web service

Posted: Mon Jan 11, 2021 5:18 pm
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.