Speed up development with full-stack environments for every branch.

Learn More

How to create a basic SOAP Server [soapserver and PHP]

1838 Runs 13140 Views 4056 Copies
Saved

Saved

gtsolutions 373

gtsolutions
published 4 years ago

<?php
/*
 * PHP SOAP - How to create a basic SOAP Server
 */

//a basic API class
class MyAPI {
    
    function hello() {
        return "Hello";
    }

}
//when in non-wsdl mode the uri option must be specified
$options=array('uri'=>'http://localhost/');
//create a new SOAP server
$server = new SoapServer(NULL,$options);
//attach the API class to the SOAP Server
$server->setClass('MyAPI');
//start the SOAP requests handler
$server->handle();
//the echo is just for demo purposes, 
//when implementing a SOAP Client no echo must be present otherwise an error will be thrown
echo "SOAP Server started";
?>
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).