Created
December 24, 2015 15:11
-
-
Save dwihujianto/b68c052a7626ba9766de to your computer and use it in GitHub Desktop.
Create Soap (MyStyle)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @author Dwi Hujianto <[email protected]> | |
*/ | |
require_once 'lib/nusoap.php'; | |
class Resourceapi extends soap_server | |
{ | |
/** | |
* set Direktori Api server | |
*/ | |
protected $targetNameSpace = 'http://localhost/soap/'; | |
/** | |
* set Method atu fungsi yang akan digunakan untuk interaksi Server | |
*/ | |
protected $method = 'credible'; | |
protected $rawPostData; | |
public function __construct() | |
{ | |
$this->rawPostData = file_get_contents('php://input'); | |
$this->create(); | |
} | |
/** | |
* Methor credible serta behavior registerMethod | |
* Silahkan modifikasi sendiri sesuai kebutuhan | |
*/ | |
public function credible($user=null,$pass=null) | |
{ | |
$data = [ | |
'user' => $user, | |
'pass' => $pass | |
]; | |
return $data; | |
} | |
private function registerMethod() | |
{ | |
$this->register | |
( | |
$this->method, | |
[ | |
'user' => 'xsd:string', | |
'pass' => 'xsd:string' | |
], | |
[ | |
'return' => 'xsd:Array' | |
], | |
$this->targetNameSpace | |
); | |
} | |
private function create() | |
{ | |
$this->configureWSDL($this->method,$this->targetNameSpace); | |
$this->wsdl->schemaTargetNamespace = $this->targetNameSpace; | |
$this->registerMethod(); | |
$this->service | |
( | |
isset($this->rawPostData) | |
? $this->rawPostData | |
: null | |
); | |
} | |
} | |
new Resourceapi(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'lib/nusoap.php'; | |
$targetNameSpace = 'http://localhost/soap/'; | |
$server = new soap_server(); | |
$server->configureWSDL('credible',$targetNameSpace); | |
$server->wsdl->schemaTargetNamespace = $targetNameSpace; | |
$server->register( | |
'credible', | |
[ | |
'username' => 'xsd:string', | |
'password' => 'xsd:string' | |
], | |
['return' => 'xsd:Array'], // Jika tunggal gunakan string saja | |
$targetNameSpace | |
); | |
function credible($username,$password) | |
{ | |
$query = [ | |
'username' => $username, | |
'password' => $password | |
]; | |
return $query; | |
} | |
$rawPostData = file_get_contents("php://input"); | |
$server->service(isset($rawPostData) ? $rawPostData : ''); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment