search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

PHP5 Web Service(SOAP)標準範例 – jashliao部落格

PHP5 Web Service(SOAP)標準範例

 

資料來源: https://www.youtube.com/watch?v=UEpdhxM1ikk

 

test.wsdl

  targetNamespace=’urn:myTns’

  xmlns:tns=’urn:myTns’

  xmlns:wsdl=’http://schemas.xmlsoap.org/wsdl/’

  xmlns:xsd=’http://www.w3.org/2001/XMLSchema’ 

  xmlns:soap12=’http://schemas.xmlsoap.org/wsdl/soap12/’

  xmlns=’http://schemas.xmlsoap.org/wsdl/’>

 

       

               

               

       

       

               

       

 

       

               

               

       

       

               

       

 

       

         

               

                       

                       

               

         

               

                       

                       

               

         

       

 

       

         

               

 

               

                       

                       

                               

                       

                       

                               

                       

               

         

               

                       

                       

                               

                       

                       

                               

                       

                 

         

       

 

       

               

                       

               

       

 

testclient.php

    $client = new SoapClient(“HTTP的絕對路徑/test.wsdl”, array(‘soap_version’ => SOAP_1_2,’trace’ =>  1 ));

        $a=200;

        $b=100;

    $return = $client->__soapCall(“SumData”,array(‘Sum_a’ => $a,’Sum_b’ =>$b));

    print_r($return);

        echo ‘
’;

        $return1 = $client->__soapCall(“SubData”,array(‘Sub_a’ => $a,’Sub_b’ =>$b));

        print_r($return1);

?>

testserver.php

class TestClass

{

        function SumData($a,$b)

        {

                return $a+$b;

        }

        function SubData($a,$b)

        {

                return $a-$b;

        }      

}

ini_set(“soap.wsdl_cache_enabled”, “0”); // disabling WSDL cache

$server = new SoapServer(‘HTTP的絕對路徑/test.wsdl’, array(‘soap_version’   => SOAP_1_2));

$server->setClass(‘TestClass’);

$server->handle();

?>

 

 

 



熱門推薦

本文由 jashliaoeuwordpress 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦