note 104065 added to soapvar.soapvar

From: Date: Fri, 20 May 2011 14:05:46 +0000
Subject: note 104065 added to soapvar.soapvar
Groups: php.notes 
Request: Send a blank email to php-notes+get-179902@lists.php.net to get a copy of this message
It took me more than one day to figure out how to use the SoapVar object in a multilevel/complex SOAP request. If you want to set-up a multilevel/complex SOAP call with parameters in subnodes, you can use the following methods: <?php /* Simple example with array as parameter */ $wsdl_url = ''; $client = new SoapClient($wsdl_url, array('trace' => true)); $parameters = array( 'FromCurrency' => 'EUR', 'ToCurrency' => 'AUD', ); $client->ConversionRate($parameters); echo htmlentities($client->__getLastRequest()); /* Simple example with stdClass object as parameter */ $wsdl_url = ''; $client = new SoapClient($wsdl_url, array('trace' => true)); $parameters = new stdClass(); $parameters->FromCurrency = 'EUR'; $parameters->ToCurrency = 'AUD'; $client->ConversionRate($parameters); echo htmlentities($client->__getLastRequest()); /* Example with complex/nested node structure using an array as param*/ $wsdl_url = "http://yourwsdlfile"; $client = new SoapClient($wsdl_url, array('trace' => true)); $client->YourCall(array( 'YourContainerNodeName' => array( 'Level1NodeFoo' => '100', 'Level1NodeBar' => '100', 'Subnodes' => array( 'NodeLevel2' => 'test' ) ) )); /* Example with complex/nested node structure using an stdClass as param */ $wsdl_url = "http://yourwsdlfile"; $client = new SoapClient($wsdl_url, array('trace' => true)); $params = new stdClass(); $params->YourContainerNodeName = new stdClass(); $params->YourContainerNodeName->Level1NodeFoo = 100; $params->YourContainerNodeName->Level1NodeBar = 100; $params->YourContainerNodeName->Subnodes = new stdClass(); $params->YourContainerNodeName->Subnodes->NodeLevel2 = 'test'; $client->YourCall($params); /* Example with complex/nested node structure using an stdClass and SoapVars as param */ $wsdl_url = "http://yourwsdlfile"; $client = new SoapClient($wsdl_url, array('trace' => true)); $params = new stdClass(); $params->YourContainerNodeName = new stdClass(); $params->YourContainerNodeName->Level1NodeFoo = 100; $params->YourContainerNodeName->Level1NodeBar = 100; $params->YourContainerNodeName->Subnodes = new stdClass(); $params->YourContainerNodeName->Subnodes->NodeLevel2 = new SoapVar(3, XSD_INT, 'xsd:int'); $params->YourContainerNodeName->Subnodes->NodeLevel3 = new SoapVar("<ns1:AdText><![CDATA[hallo<br><br>test]]></ns1:AdText>", XSD_ANYXML); $params->YourContainerNodeName->Subnodes->NodeLevel4 = array( new SoapVar(1, XSD_INT, 'xsd:int'), new SoapVar(2, XSD_INT, 'xsd:int'), new SoapVar(3, XSD_INT, 'xsd:int') ); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 213.125.78.122 ---- Manual Page -- http://www.php.net/manual/en/soapvar.soapvar.php Edit -- https://master.php.net/note/edit/104065 Del: integrated -- https://master.php.net/note/delete/104065/integrated Del: useless -- https://master.php.net/note/delete/104065/useless Del: bad code -- https://master.php.net/note/delete/104065/bad+code Del: spam -- https://master.php.net/note/delete/104065/spam Del: non-english -- https://master.php.net/note/delete/104065/non-english Del: in docs -- https://master.php.net/note/delete/104065/in+docs Del: other reasons-- https://master.php.net/note/delete/104065 Reject -- https://master.php.net/note/reject/104065 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179902) next »