{"id":288,"date":"2011-12-08T03:21:24","date_gmt":"2011-12-08T08:21:24","guid":{"rendered":"http:\/\/www.g31zone.com\/?p=288"},"modified":"2014-09-09T08:30:31","modified_gmt":"2014-09-09T13:30:31","slug":"php-soap-sample","status":"publish","type":"post","link":"https:\/\/www.g31zone.com\/?p=288","title":{"rendered":"PHP &#8211; SOAP sample"},"content":{"rendered":"<h3>PHP simple SOAP sample<\/h3>\n<p>SOAP server file (soapserver.php): <\/p>\n<p><code><br \/>\n&lt;?php<br \/>\n\t\/\/ Set a function in SOAP server file<br \/>\n\tfunction hello($someone)<br \/>\n\t{<br \/>\n\t\treturn \"Hello \" . $someone . \"!\";<br \/>\n\t}<br \/>\n\t\/\/ Create a new SOAP server<br \/>\n\t$server = new SoapServer(null, array('uri' =&gt; \"urn:\/\/g31.local\/ex\/res\"));<br \/>\n\t\/\/ Add function to SOAP server<br \/>\n\t$server->addFunction(\"hello\");<br \/>\n\t\/\/ Handle SOAP server<br \/>\n\t$server->handle();<br \/>\n?&gt;<br \/>\n<\/code><\/p>\n<p>SOAP client file (soapclient.php): <\/p>\n<p><code><br \/>\n&lt;?php<br \/>\n\t\/\/ Set new soap client<br \/>\n\t$client = new SoapClient(null, array(<br \/>\n\t\t'location' =&gt; \"http:\/\/localhost\/soapsample\/soapserver.php\",<br \/>\n\t\t'uri'      =&gt; \"urn:\/\/localhost\/soapsample\/req\",<br \/>\n\t\t'trace'    =&gt; 1 ));<br \/>\n\t\/\/ Call SOAP<br \/>\n\t$return = $client->__soapCall(\"hello\", array(\"User\"));<br \/>\n\t\/\/ Dispay request\/response informations<br \/>\n\techo(\"\\nReturning value of __soapCall() call: \" . $return);<br \/>\n\techo(\"\\nDumping request headers:\\n\" . $client->__getLastRequestHeaders());<br \/>\n\techo(\"\\nDumping request:\\n\" . $client->__getLastRequest());<br \/>\n\techo(\"\\nDumping response headers:\\n\" . $client->__getLastResponseHeaders());<br \/>\n\techo(\"\\nDumping response:\\n\" . $client->__getLastResponse());<br \/>\n?&gt;<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP simple SOAP sample SOAP server file (soapserver.php): &lt;?php \/\/ Set a function in SOAP server file function hello($someone) { return &#8220;Hello &#8221; . $someone&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[18,99,102,100,101],"class_list":["post-288","post","type-post","status-publish","format-standard","hentry","category-php","tag-php-2","tag-soap","tag-soap-client","tag-soap-sample","tag-soap-server"],"_links":{"self":[{"href":"https:\/\/www.g31zone.com\/index.php?rest_route=\/wp\/v2\/posts\/288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.g31zone.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.g31zone.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.g31zone.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.g31zone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=288"}],"version-history":[{"count":6,"href":"https:\/\/www.g31zone.com\/index.php?rest_route=\/wp\/v2\/posts\/288\/revisions"}],"predecessor-version":[{"id":413,"href":"https:\/\/www.g31zone.com\/index.php?rest_route=\/wp\/v2\/posts\/288\/revisions\/413"}],"wp:attachment":[{"href":"https:\/\/www.g31zone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.g31zone.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.g31zone.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}