PHP5的SOAP
想請問一下
Apache Web Server Version 2.0.55
PHP Script Language Version 5.1.1
MySQL Database Version 5.0.16
phpMyAdmin Database Manager Version 2.6.4-pl4
在上述的環境下
而且我有設定ini檔裡面的extension = php_soap.dll
可是下面這些code卻沒有辦法執行
想要測試SOAP的功能
下面依序是三個檔案
謝謝大家了<(_ _)>
----------------------------------------------------------------------------
temperature.wsdl
<?xml version ='1.0' encoding ='UTF-8' ?>
<definitions name='Temperature'
targetNamespace='http://example.org/temperature'
xmlns:tns=' http://example.org/temperature '
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<message name='getTempRequest'>
<part name='symbol' type='xsd:string'/>
</message>
<message name='getTempResponse'>
<part name='Result' type='xsd:float'/>
</message>
<portType name='TempPortType'>
<operation name='getTemp'>
<input message='tns:getTempRequest'/>
<output message='tns:getTempResponse'/>
</operation>
</portType>
<binding name='TempBinding' type='tns:TempPortType'>
<soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='getTemp'>
<soap:operation soapAction='urn:localhost-temperature#getTemp'/>
<input>
<soap:body use='encoded' namespace='urn:localhost-temperature'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='encoded' namespace='urn:localhost-temperature'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
</binding>
<service name='TemperatureService'>
<port name='TempPort' binding='TempBinding'>
<soap:address location='http://localhost/phptest/server.php'/>
</port>
</service>
</definitions>
---------------------------------------------------------------------------
server.php
<?php
function getTemp($zip) {
$temp = rand(40,80);
return $temp;
}
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("temperature.wsdl");
$server->addFunction("getTemp");
$server->handle();
?>
------------------------------------------------------------------------------
client.php
<?php
$ZIP = $_GET['zipcode'];
$client = new SoapClient("temperature.wsdl");
$return = $client->getTemp($ZIP);
echo("Temperature is: " . $return);
?>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.204.245
→
05/29 16:21, , 1F
05/29 16:21, 1F
→
05/29 16:22, , 2F
05/29 16:22, 2F
推
06/01 10:25, , 3F
06/01 10:25, 3F
PHP 近期熱門文章
PTT數位生活區 即時熱門文章