note 83028 deleted from ref.soap by cmb

From: Date: Sun, 24 Nov 2019 08:28:36 +0000
Subject: note 83028 deleted from ref.soap by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213173@lists.php.net to get a copy of this message
Note Submitter: aeolianmeson at dontfindme dot blitzeclipse dot com ---- A quick example to do a login using a WSDL, do a second request using the session ID from the login response, and then dump the XML from that request. // Setting "trace" will allow us to view the request that we are making, after we have made it. $objClient = new SoapClient("http://www.somewhere.com/wsdls/some.wsdl", array('trace' => true)); // These parameters satisfy this specific remote call. $arrParameters_Login = array('username' => 'username', 'password' => 'password', 'company' => 'Company'); // Invoke the remote call "login()". $objLogin = $objClient->login($arrParameters_Login); // Grab session ID that this remote call will provide. $strSessionID = $objLogin->loginReturn->sessionId; // Set headers-- The remote call "query()" will require a header pointing to our session. $strHeaderComponent_Session = "<SessionHeader><sessionId>$strSessionID</sessionId></SessionHeader>"; $objVar_Session_Inside = new SoapVar($strHeaderComponent_Session, XSD_ANYXML, null, null, null); $objHeader_Session_Outside = new SoapHeader('namespace.com', 'SessionHeader', $objVar_Session_Inside); // More than one header can be provided in this array. $objClient->__setSoapHeaders(array($objHeader_Session_Outside)); // Set the query parameters. $strQuery = 'select empID from Time where empID = 92389278'; $arrParameters_Query = array('queryString' => $strQuery); // Make call. $objResponse = $objClient->query($arrParameters_Query); header('Content-Type: text/xml; '); print($objClient->__getLastRequest()); The request that goes out: <SOAP-ENV:Envelope> <SOAP-ENV:Header> <SessionHeader> <sessionId>8789364113604871127</sessionId> </SessionHeader> </SOAP-ENV:Header> <SOAP-ENV:Body> <ns1:query> <ns1:queryString>select empID from Time where empID = 92389278</ns1:queryString> </ns1:query> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

« previous php.notes (#213173) next »