Problem while explorin SOAP web service

Hi,

I’m trying out Yii’s SOAP features. I had no problem getting the simple quote example to work, but I cannot get the more complex post example to work.

The error is: "Description: looks like we got no XML document(sic)".

The offending code is:




  $post_client = new SoapClient('http://blah/webservice/post/service');

  $posts = $post_client->getPosts();



where the failure is in the call to getPosts().

However, a call to http://blah/webservice/post/service displays the WSDL, and it looks okay, and a call to __getFunctions() on the SoapClient displays:




array(

[0] =>

'PostArray getPosts()'

)



The top of the stack trace is:




#0 [internal function]: SoapClient->__call('getPosts', Array)

#1 .../webservice/protected/controllers/SiteController.php(23): SoapClient->getPosts()



That ‘Array’ in __call looks odd.

Any ideas? Thanks.

Here’s the WSDL:




<?xml version="1.0" encoding="UTF-8"?>

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="urn:PostControllerwsdl" 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="PostController" targetNamespace="urn:PostControllerwsdl">

 <wsdl:types>

  <xsd:schema targetNamespace="urn:PostControllerwsdl">

   <xsd:complexType name="PostArray">

    <xsd:complexContent>

     <xsd:restriction base="soap-enc:Array">

      <xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="tns:Post[]"/>

     </xsd:restriction>

    </xsd:complexContent>

   </xsd:complexType>

   <xsd:complexType name="Post">

    <xsd:all>

     <xsd:element name="id" type="xsd:integer"/>

     <xsd:element name="title" type="xsd:string"/>

    </xsd:all>

   </xsd:complexType>

  </xsd:schema>

 </wsdl:types>

 <wsdl:message name="getPostsRequest"/>

 <wsdl:message name="getPostsResponse">

  <wsdl:part name="return" type="tns:PostArray"/>

 </wsdl:message>

 <wsdl:portType name="PostControllerPortType">

  <wsdl:operation name="getPosts">

   <wsdl:documentation></wsdl:documentation>

   <wsdl:input message="tns:getPostsRequest"/>

   <wsdl:output message="tns:getPostsResponse"/>

  </wsdl:operation>

 </wsdl:portType>

 <wsdl:binding name="PostControllerBinding" type="tns:PostControllerPortType">

  <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>

  <wsdl:operation name="getPosts">

   <soap:operation soapAction="urn:PostControllerwsdl#getPosts" style="rpc"/>

   <wsdl:input>

    <soap:body use="encoded" namespace="urn:PostControllerwsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>

   </wsdl:input>

   <wsdl:output>

    <soap:body use="encoded" namespace="urn:PostControllerwsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>

   </wsdl:output>

  </wsdl:operation>

 </wsdl:binding>

 <wsdl:service name="PostControllerService">

  <wsdl:port name="PostControllerPort" binding="tns:PostControllerBinding">

   <soap:address location="http://blah/webservice/post/service/ws/1"/>

  </wsdl:port>

 </wsdl:service>

</definitions>



what is your doc comment to getPosts()?

Thanks for the offer of help, but I got there in the end. I had no:




  public static function model($className=__CLASS__) {

    return parent::model($className);

  }



…in my Post model. I copied and pasted from the example instead of generating the model, and omitted to add it. Mea culpa.

Still, it was a useful exercise debugging SOAP in Yii.

I’ll suggest adding that line to the example to save someone else doing the same thing.