soap - Returning a PHP Array from a PHP SoapServer -
I'm relatively new to soap on "creating service side", so Munging by me in advance for any terminology.
Is it possible to return a PHP array backed by a remote process soap service setup using PHP's SOAP server class?
I have a WSDL (a tutorial is made of blind) that, in part, looks like something
& Lt; / Messages & gt; & Lt; PortType name = 'FtaPortType' & gt; & Lt; Operation name = 'query' & gt; & Lt; Input message = 'tns: generic string' / & gt; & Lt; Output message = 'tns: generic object' /> & Lt; / Operation & gt; & Lt; / PortType & gt;
The PHP method I am calling is given the query name, and something looks like
public function query ($ arg) {$ Object = new stdClass (); $ Object-> Test = $ arg; Return objects; }
This allows me to call
$ client = new SOAP client ("http://example.com/my.wsdl" ); $ Result = $ client- & gt; Query ('this is an exam');
More results will show a dump
object (stdClass) [2] public 'results' => I want to return a basic PHP array / archive to my query method: string 'this is an exam' (length = 18)
If I change my query method to return an array
public function query ($ arg) {$ object = array ('test', 'again'); Return objects; }
This is sorted in the object on the client side.
object (stdClass) [2] public 'item' = & gt; Array 0 = & gt; String 'test' (length = 4) 1 = & gt; String 'again' (length = 5)
This is understood, as I did in a specific xsd: object
result type in my WSDL I would like, if possible, return a basic PHP array that is not wrapped in an object. My tendency says that there is a specific xsd: type that will allow me to complete it, but I do not know. I was also serialized for the object as an ArrayObject
.
Do not hold me back on school education in OSWSL
I am trying to understand the underlying concepts for / P>
Returning an array of strings is what my web service does, here is a part of WSDL:
& lt; Wsdl: types & gt; & Lt; Xsd: Schema Targetpoint = "http://schema.example.com" & gt; & Lt; Xsd: complex type name = "string array" & gt; & Lt; XSD: complexContent & gt; & Lt; Xsd: restriction base = "SOAP-ENC: Array" & gt; & Lt; Xsd: attribute ref = "SOAP-ENC: array type" wsdl: arrayType = "xsd: string []" /> & Lt; / XSD: Ban & gt; & Lt; / XSD: complexContent & gt; & Lt; / XSD: complexType & gt; & Lt; / XSD: Schema & gt; & Lt; / Wsdl: type & gt; & Lt; Message Name = "Notification" & gt; & Lt; Part name = "parameter" type = "xsd: string" /> & Lt; / Messages & gt; & Lt; Message Name = "Notification" & gt; & Lt; Part name = "notifyReturn" type = "tns: stringArray" /> & Lt; / Messages & gt;
then define the API function notify
:
& lt; Wsdl: operation name = "notify" & gt; & Lt; Wsdl: input message = "tns: notifyRequest" /> & Lt; Wsdl: output message = "tns: notifyResponse" /> & Lt; / Wsdl: operation & gt;
Comments
Post a Comment