Hi !
Im trying to make work the Web Service example in the Yiis Doc Guide.
This is my controller :
class GolController extends CController
{
public function actions()
{
return array(
'quote'=>array(
'class'=>'CWebServiceAction',
),
);
}
/**
* @param string the symbol of the stock
* @return float the stock price
* @soap
*/
public function getPrice($symbol)
{
$prices=array('IBM'=>100, 'GOOGLE'=>350);
return isset($prices[$symbol])?$prices[$symbol]:0;
//...return stock price for $symbol
}
}
When i browse my controller/action like : http://myrealdomain.com/gol/quote
I see the following XML :
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="urn:GolControllerwsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" name="GolController" targetNamespace="urn:GolControllerwsdl"><wsdl:message name="getPriceRequest"><wsdl:part name="symbol" type="xsd:string"/></wsdl:message><wsdl:message name="getPriceResponse"><wsdl:part name="return" type="xsd:float"/></wsdl:message><wsdl:portType name="GolControllerPortType"><wsdl:operation name="getPrice"><wsdl:documentation></wsdl:documentation><wsdl:input message="tns:getPriceRequest"/><wsdl:output message="tns:getPriceResponse"/></wsdl:operation></wsdl:portType><wsdl:binding name="GolControllerBinding" type="tns:GolControllerPortType"><soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/><wsdl:operation name="getPrice"><soap:operation soapAction="urn:GolControllerwsdl#getPrice" style="rpc"/><wsdl:input><soap:body use="encoded" namespace="urn:GolControllerwsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></wsdl:input><wsdl:output><soap:body use="encoded" namespace="urn:GolControllerwsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="GolControllerService"><wsdl:port name="GolControllerPort" binding="tns:GolControllerBinding"><soap:address location="http://myrealdomain.com/gol/quote/ws/1"/></wsdl:port></wsdl:service></definitions>
But when i try to access it from the same server with this client :
<?php
try {
$client=new SoapClient('http://myrealdomain.com/gol/quote');
$client->getPrice('GOOGLE');
}
catch (SoapFault $e)
{
echo "<pre>";
print_r($e);
echo "</pre>";
}
?>
I got the following error :
Warning: SoapClient::SoapClient(http://myrealdomain.com/gol/quote) [soapclient.soapclient]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found <br /> HTTP request failed! HTTP/1.1 404 Not Found in /home/sperez/html/sdg/public/soap.php on line 8
Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "http://myrealdomain.com/gol/quote" in /home/sperez/html/sdg/public/soap.php on line 8
SoapFault Object
(
[message:protected] => SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://myrealdomain.com/gol/quote'
[string:private] =>
[code:protected] => 0
[file:protected] => /home/sperez/html/sdg/public/soap.php
[line:protected] => 8
[trace:private] => Array
(
[0] => Array
(
[file] => /home/sperez/html/sdg/public/soap.php
[line] => 8
[function] => SoapClient
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => http://myrealdomain.com/gol/quote
[1] => Array
(
[compression] => 32
[encoding] => UTF-8
)
)
)
)
[faultstring] => SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://myrealdomain.com/gol/quote'
[faultcode] => WSDL
)
What is going on?
Im using php 5.2.6
regards