Re: wsdl complex types help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




I am trying to use soapclient to connect to a web service. Unfortunately, I'm having trouble figuring out how to get php to understand the wsdl file and send back the correct message - particularly on a function that wants an array that forms a complex type.


Replying to myself just in case anyone else has similar issues. I found a work-around that will at least get me up and running.

I found that I can simply construct the correct xml message and send it over with __doRequest which simply returns the response. This works OK since the reply value is simply a boolean anyway in my case, so parsing that will be pretty easy. However, it would be nice if I could just call the function and have soapclient understand how to construct it.

But, here is what I did.

$client = new SoapClient($wsdl,$options);
$location = "http://urlto/webservice";;
$hostkey = "1.1.1.1";
$username = "username";
$password = "password";
$auth = getAuthXML($hostkey,$username,$password);
$response = $client->__doRequest($auth,$location,$action,$version);
print $response; # in my case response is true/false

The getAuthXML function is simply taking the variables I want to use and constructing an xml message from it. The __doRequest then sends over that XML message. This is vs calling the authenticate function and having soapclient attempt to construct the xml message itself based on your arguments.

function getAuthXML($hostkey,$username,$password) {
  $auth = <<<EOD
<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsd="http://w ww.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
 <soapenv:Body>
<ns1:authenticate soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:ns1
="http://common.wsg.sesm.cisco.com";>
<hostkey xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";>$
hostkey</hostkey>
<credentials xsi:type="soapenc:Array" soapenc:arrayType="ns1:Credential[1]" xmlns:soapenc="h
ttp://schemas.xmlsoap.org/soap/encoding/">
    <item href="#id0"/>
   </credentials>
  </ns1:authenticate>
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/en coding/" xsi:type="ns2:Credential" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; xm
lns:ns2="http://common.wsg.sesm.cisco.com";>
 <identity href="#id1"/>
   <credential xsi:type="soapenc:string">$password</credential>
  </multiRef>
<multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/en coding/" xsi:type="ns3:Identity" xmlns:ns3="http://common.wsg.sesm.cisco.com"; xmlns:soapenc="ht
tp://schemas.xmlsoap.org/soap/encoding/">
   <type xsi:type="soapenc:string">user</type>
   <principal xsi:type="soapenc:string">$username</principal>
  </multiRef>
 </soapenv:Body>
</soapenv:Envelope>
EOD;
  return $auth;
}

Hope that helps someone. If anyone does still have advice on correcting my wsdl file or php workaround for this (perhaps classmap?), I'd love to hear them.

Thanks
Dusty Doris

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux