SOAP-ERROR: Parsing WSDL

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

Just try : http://myrealdomain.com/gol/quote

and you should get the WSDL

I tried yor example and got this!

But still and CHttpException exception as follows.

[faultstring] =&gt; CHttpException


[faultcode] =&gt; HTTP

SoapFault Object

(

[message:protected] =&gt; CHttpException


[string:Exception:private] =&gt; 


[code:protected] =&gt; 0


[file:protected] =&gt; G:&#092;home&#092;www&#092;gemisoft.com&#092;protected&#092;controllers&#092;SiteController.php


[line:protected] =&gt; 32


[trace:Exception:private] =&gt; Array


    (


        [0] =&gt; Array


            (


                [function] =&gt; __doRequest


                [class] =&gt; SoapClient


                [type] =&gt; -&gt;


                [args] =&gt; Array


                    (


                        [0] =&gt; 

GOOGLE

                        [1] =&gt; http://localhost/gemiauth/stock/quote/ws/1.html


                        [2] =&gt; urn:StockControllerwsdl#getPrice


                        [3] =&gt; 1


                        [4] =&gt; 0


                    )





            )





        [1] =&gt; Array


            (


                [function] =&gt; __call


                [class] =&gt; SoapClient


                [type] =&gt; -&gt;


                [args] =&gt; Array


                    (


                        [0] =&gt; getPrice


                        [1] =&gt; Array


                            (


                                [0] =&gt; GOOGLE


                            )





                    )





            )





        [2] =&gt; Array


            (


                [file] =&gt; G:&#092;home&#092;www&#092;gemisoft.com&#092;protected&#092;controllers&#092;SiteController.php


                [line] =&gt; 32


                [function] =&gt; getPrice


                [class] =&gt; SoapClient


                [type] =&gt; -&gt;


                [args] =&gt; Array


                    (


                        [0] =&gt; GOOGLE

    )





[previous:Exception:private] =&gt; 


[faultstring] =&gt; CHttpException


[faultcode] =&gt; HTTP

)

Hi !

I got an WSDL parsing error because my server cant resolve his own domain name.

Hi ,

I faced the same issue. But i was using ‘localhost’. Later i resumed using ‘IP Address’ and its working fine.

I got a worse error xml parsing error : junk after document element???

Do you have web logging/profiling enabled?

/Tommy