note 59859 added to ref.soap

From: Date: Sun, 18 Dec 2005 16:12:52 +0000
Subject: note 59859 added to ref.soap
Groups: php.notes 
Request: Send a blank email to php-notes+get-100374@lists.php.net to get a copy of this message
Here's an example on how to pass ArrayOfAnyType arguments containing complex types. Suppose your WSDL file defines "http://any.url.com/" as the default namespace and a complex type "SomeComplexType". If you want to call a WebServices which takes an ArrayOfAnyType argument of "SomeComplexType"s you need to perform the following: <?php // complexTypes being an array containing several instances of SomeComplexType myWSParameter = array(); foreach (complexTypes as ct) { // Don't mispell the type or the namespace. Also note that php won't assume the default namespace defined in the WSDL file. myWSParameter []= new SoapVar(ct, 0, "SomeComplexType", "http://any.url.com/"); } ?> On the other hand, when a WebService returns an ArrayOfAnyType you have to do the following to access each of its elements. <?php // Here, we will be echoing each return item $res = $someWS->myFunction($myArgs) // If only one element is returned, an array won't be built if (is_array(myFunctionResult->anyType)) { foreach (myFunctionResult->anyType as $soapVar) { echo $soapVar->enc_value; } } else { echo myFunctionResult->anyType->enc_value; } ?> This has all been tested using a .NET WebService. ---- Manual Page -- http://www.php.net/manual/en/ref.soap.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+59859 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59859&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59859&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59859&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59859&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59859&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59859&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59859&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+59859&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#100374) next »