简体   繁体   English

用php和wsdl进行肥皂查询以获得结果

[英]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. 我很难找到一个很好的例子,说明如何用php中的wsdl进行肥皂调用。

I found this example, but it's tied to the google function: 我找到了这个示例,但它与google函数相关:

doGoogleSearch 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: 我为wsdl找到了这个示例,但是没有看到查询的位置:

missingQuery 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 //然后我将使用正则表达式从$ result中提取$ varAnswer

This is really unclear. 这真的不清楚。 Does anyone have any helpful info on how to submit the query to the DB with the WSDL? 是否有人有关于如何使用WSDL将查询提交到数据库的有用信息? I shouldn't have to give the soap call a specific function to do the query with. 我不必给soap调用一个特定的函数来执行查询。 It's supposed to get that from the wsdl definition. 应该从wsdl定义中得到。

Why not use the built in SoapClient . 为什么不使用内置的SoapClient呢 It will convert the input to the function into a Soap Message and extract the return message into an object; 它将输入到函数的信息转换为Soap Message,然后将返回信息提取为对象。 based on the WSDL. 基于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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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