简体   繁体   中英

soap query with php and wsdl to get result

I'm having trouble finding a good example of how to do a soap call with a wsdl in php.

I found this example, but it's tied to the google function:

doGoogleSearch

$hits = $soap->doGoogleSearch('your google key',$query,0,10,
                               true,'',false,'lang_en','','');

I found this example for a wsdl, but I'm not seeing where my query goes:

missingQuery

So basically, this is what I have so far, but there's a lot missing:

$wsdlDB = "htmlString?wsdl";
// xml string for login and query I know works in soapUI with $var
    $query = "$query = 
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tri="http://blah/dbOurs/">
   <soapenv:Header/>
   <soapenv:Body>
      <tri:sendTransaction>
        <loginName>unernm</loginName>
         <loginPassword>pw</loginPassword>
                ...
   </soapenv:Body>
</soapenv:Envelope>'

$result = "not sure where this ties in either";

$WSDL = new SOAP_WSDL($wsdlDB);
$soap = $WSDL->getProxy();

$hits = $soap->($query, $result);

//then I will extract $varAnswer from $result with regex probably

This is really unclear. Does anyone have any helpful info on how to submit the query to the DB with the WSDL? I shouldn't have to give the soap call a specific function to do the query with. It's supposed to get that from the wsdl definition.

Why not use the built in SoapClient . It will convert the input to the function into a Soap Message and extract the return message into an object; based on the WSDL.

A simple sample is shown below.

$blzCode = '10010424'; // Code to lookup
$wsdlDB = "http://www.thomas-bayer.com/axis2/services/BLZService?wsdl"; // WSDL URL
$client = new SoapClient($wsdlDB); // Create the client based on the WSDL
$returnValue = $client->GetBank(array('blz' => $blzCode)); // Pass in the Parameters to the call (Based on the WSDL's definition)
$bankDetails = $returnValue->details; // Extract the results
$bankName = $bankDetails->bezeichnung; // Extract some portion of the inner result
echo "Blz Code {$blzCode}'s bank name is {$bankName}" . PHP_EOL; // Do something with the data

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM