使用php和wsdl查询soap以获得结果

问题描述 投票:0回答:1

我很难找到一个很好的例子,说明如何在php中使用wsdl进行soap调用。

我找到了这个例子,但它与谷歌功能有关:

doGoogleSearch

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

我为wsdl找到了这个例子,但是我没有看到我的查询在哪里:

missingQuery

所以基本上,这是我到目前为止所做的,但是有很多缺失:

$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);

//然后我会用正则表达式从$ result中提取$ varAnswer

这真的不清楚。有没有人有关于如何使用WSDL将查询提交到数据库的任何有用信息?我不应该给soap调用一个特定的函数来进行查询。它应该从wsdl定义中得到它。

php soap wsdl
1个回答
0
投票

为什么不使用内置的SoapClient。它会将函数的输入转换为Soap消息,并将返回消息提取到对象中;基于WSDL。

一个简单的样本如下所示。

$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
© www.soinside.com 2019 - 2024. All rights reserved.