Published on WSO2 Oxygen Tank (http://wso2.org)

Problem webservice consume for client

By faborm
Created 2008-05-08 08:25

Hi,





I'm doing a test, but I have a problem. I'm did a server with WSO2 framework for php using WSDL API generation. The source of the server is:



/**

 * class student

 * @namespace http://test

 */

class Student

{

    /**

     * @property string id

     * (maps to the xs:string XML schema type )

     */

    public $id;

  

    public function __construct($id)

    {

        $this->id = $id;

    }

  

}





/**

 * @return array of object Student $a

 * (maps to the xs:anyType XML schema type )

 */

function getStudents()

{

    $a = array();

  

    for($i = 0; $i <= 2; $i++)

    {

        $a[$i] = new Student("$i");

    }

  

    return $a;

  

}





$operations = array("getStudents");

$service = new WSService(array("operations" => $operations));

$service->reply();





The wsdl output is ok, that is:





    <definitions targetNamespace="http://www.wso2.org/php">



    <types>



    <xsd:schema elementFormDefault="qualified" targetNamespace="http://www.wso2.org/php">



    <xsd:element name="getStudentsResponse">



    <xsd:complexType>



    <xsd:sequence>

<xsd:element name="a" maxOccurs="unbounded" type="ns0:Student"/>

</xsd:sequence>

</xsd:complexType>

</xsd:element>

</xsd:schema>



    <xsd:schema elementFormDefault="qualified" targetNamespace="http://test">



    <xsd:complexType name="Student">



    <xsd:sequence>

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

</xsd:sequence>

</xsd:complexType>

</xsd:schema>

</types>



    <message name="getStudents">

<part name="parameters" element="tns:getStudents"/>

</message>



    <message name="getStudentsResponse">

<part name="parameters" element="tns:getStudentsResponse"/>

</message>



    <portType name="~fabio_wso2service_service.phpPortType">



    <operation name="getStudents">

<input message="tns:getStudents"/>

<output message="tns:getStudentsResponse"/>

</operation>

</portType>



    <binding name="~fabio_wso2service_service.phpSOAPBinding" type="tns:~fabio_wso2service_service.phpPortType">

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



    <operation name="getStudents">

<soap:operation soapAction="http://200.17.41.239/~fabio/wso2service/service.php/getStudents" style="document"/>



    <input>

<soap:body use="literal"/>

</input>



    <output>

<soap:body use="literal"/>

</output>

</operation>

</binding>



    <service name="~fabio_wso2service_service.php">



    <port name="~fabio_wso2service_service.phpSOAPPort_Http" binding="tns:~fabio_wso2service_service.phpSOAPBinding">

<soap:address location="http://localhost/~fabio/wso2service/service.php"/>

</port>

</service>

</definitions>





When I use the webservice in client, a error message is displayed.



The source of client is:





class Student {

    public $id; // string

}



// define the class map

$class_map = array("Student" => "Student");



    $client = new WSClient(array ("wsdl" =>"http://localhost/~fabio/wso2service/service.php?wsdl",

        "classmap" => $class_map));



    $proxy = $client->getProxy();

    $response = $proxy->getStudents();



When the $proxy->getStudents() method is called the mensage error is displayed:



Fatal error: Uncaught exception 'DOMException' with message 'Namespace Error' in /usr/lib/php5/20060613+lfs/wsf_php/scripts/dynamic_invocation/wsf_wsdl_client_request.php:186 Stack trace: #0 /usr/lib/php5/20060613+lfs/wsf_php/scripts/dynamic_invocation/wsf_wsdl_client_request.php(186): DOMDocument->createElementNS(NULL, 'ns1:getStudents') #1 wsf_wsdl.php(156): wsf_create_payload(Object(DOMElement), true, 'getStudents', 0, Array, Array) #2 [internal function]: wsf_process_wsdl(Array, Array) #3 [internal function]: WSClientProxy->__call('getStudents', Array) #4 /home/fabio/workspace/wso2service/client.php(16): WSClientProxy->getStudents() #5 {main} thrown in /usr/lib/php5/20060613+lfs/wsf_php/scripts/dynamic_invocation/wsf_wsdl_client_request.php on line 186



 

I tried everything to find out the cause of the problem, but not succeeded.

Someone help me?



Sorry my poor english


Source URL:
http://wso2.org/forum/thread/3561