tags:

views:

83

answers:

1

i want to map an existent type to wsdl type

the wsdl complex type

 <types>
  <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/service1/"&gt;
   <xsd:complexType name="RequestDescriptor">
    <xsd:all>
     <xsd:element name="language" type="xsd:string" default="xx"></xsd:element>
     <xsd:element name="siteAPIKey" type="xsd:string" default="xxxx"></xsd:element>
     <xsd:element name="userID" type="xsd:int" default="-1"></xsd:element>
     <xsd:element name="sessionID" type="xsd:string" default="-1"></xsd:element>
     <xsd:element name="returnDataFormat" type="xsd:string" default="XX"></xsd:element>
    </xsd:all>
   </xsd:complexType>
  </xsd:schema>
 </types>

and i call it like

<wsdl:message name="getXXRequest">
  <wsdl:part name="requestDescriptor" type="xsd1:RequestDescriptor"/>
 </wsdl:message>
 <wsdl:message name="getXXResponse">
  <wsdl:part name="getXXResponse" type="xsd:anytype"/>
 </wsdl:message>

in the php i use this code to map complex type

$soapClient = new SoapClient($soapServiceURL,array("classmap"=>array("RequestDescriptor","RequestDescriptor")));

when i call any function i got in the server log this message

PHP Catchable fatal error: Argument 1 passed to xx::XXX() must be an instance of RequestDescriptor, instance of stdClass given

but it run and return the result as expected any clue how to fix this {PHP Catchable fatal error}

A: 

Does your RequestDescriptor class you claim to send have any further functionality besides being a struct / variable holder? If not, drop the classmap thing and keep on throwing stdClass objects in it.

If it does something else, you'll have to track down where an stdClass object is passed instead of an RequestDescriptor instance (probably at a location you don't expect, as the request would fail AFAIK, so there are more requests handled). A backtrace from that instance could help you a lot, possibly extend your soapclient class with another having a custom __call() method which explicitly tests for this, does a debug_print_backtrace() when the error condition occurs, or just calls parent::__call() when all's fine.

Wrikken
first : RequestDescriptor is only a bean (data holder Class) ..second : i had delegated the soapclient into a proxy class , also i checked if the args include stdClass but yet it doesn't i think the problem in wsdl file
S.Hawary
No, the problem is not in the WSDL file. The problem is in an argument you pass. You put an anonymous / stdClass object in a functions argument while you previously claimed to only want RequestDescriptotr instances there. So, fix that (or show the code calling the client).
Wrikken
hay man ... i am the one who write the code and i know what args i passed ... simple as i told u i had delegated the class in to proxy and before i call the SoapClient object i print the data and it was only an object of RequestDescriptor and the code is as the following function XXXX(......){print_r($args); /*print array (requestDescriptor object details) not stdclass*/return soapClient->__soapCall($functionName,$args);}
S.Hawary
Care to share the `print_r` argument details? Maybe you'veforgotten to wrap it in an array or something else equally trivial. Also: you may be writing the code, but you're looking for help. PHP doesn't lie: you pass an stdObject somewhere, possibly at an unexpected location, but I trust the PHP error log more then you, no offense ;)
Wrikken