Php Soap function arguments -
i'm trying create simple php soap server.
the problem although set specific parameters types in wsdl file, in case set integer, can make method calls php parameter type(string, array, assoc array).
theoretically , if php parameter type not same wsdl parameter type should not throw error? in case if call function array on server array, i call same function string on server string etc.
how cand edit code below method "domybooksearch" accept integers declared on wsdl.
client code:
try{ $sclient = new soapclient('sample.wsdl',array('trace'=>true)); print_r($sclient->domybooksearch('test')); //i call function string, , not integer wsdl } catch(soapfault $e){ var_dump($e); }
server code:
$server = new soapserver("sample.wsdl"); function domybooksearch($yourname){ return 'works'; //return string }
wsdl:
<types> <xsd:schema xmlns="http://www.w3.org/2001/xmlschema" targetnamespace="urn:mybooksearch"> <xsd:element name="booktitle"> <xsd:simpletype> <xsd:restriction base="xsd:integer"> <xsd:mininclusive value="0"/> <xsd:maxinclusive value="120"/> </xsd:restriction> </xsd:simpletype> </xsd:element> </xsd:schema> </types> <message name="domybooksearch"> <part name="booktitle" type="tns:booktitle" /> </message> <message name="domybooksearchresponse"> <part name="return" type="xsd:string" /> </message> <porttype name="mybooksearchport"> <operation name="domybooksearch"> <input message="tns:domybooksearch" /> <output message="tns:domybooksearchresponse" /> </operation> </porttype>
php not care types in case. according experience soap , php, variables send/received string , not respect restrictions of wsdl file.
one way live check in domybooksearch() function, , throw error if needed.
Comments
Post a Comment