试图让PHP发布来自WSDL调用的响应

时间:2016-08-18 16:40:15

标签: php web-services soap wsdl

我无法让我的表单进行ID查找,并通过PHP从WSDL调用中解析响应。使用BLZ唯一ID 10000000,与该BLZ唯一ID对应的名称是Bundesbank。

以下是HTML部分:

<html>
<head>
<body>
<form name="myForm" id="frm1" action="idresponse.php" method="POST">
    <input name="userID" placeholder="Enter ID">
    <input type="Submit"></b>
</form>
<b></b>    
<input name="responseID" id="frm2" placeholder="ID response from WSDL call"></input>
</body>
</head>
</html>

这是PHP部分:

<?php
    $soapClient = new SoapClient("http://www.thomas-bayer.com/axis2/services/BLZService?wsdl",array( "trace" => 1));
    $blz_param = array (
        'blz' => "10000000",
        );
$info = $soapClient->__call("CheckSomething", array($service_param));
echo "Request :\n".htmlspecialchars($soapClient->__getLastRequest()) ."\n";
?>

用例:

-User enters 10000000 into BLZ number field box.
-Code takes BLZ number and does a request and lookup from WSDL url.
-Response from WSDL url sends name of banking institution from BLZ number 10000000.
-From BLZ number 10000000, bank name should be Bundesbank.

WSDL网址:

http://www.thomas-bayer.com/axis2/services/BLZService?wsdl

INPUT WSDL(从SoapUI映射):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:blz="http://thomas-bayer.com/blz/">
   <soapenv:Header/>
   <soapenv:Body>
      <blz:getBank>
         <blz:blz>10000000</blz:blz>
      </blz:getBank>
   </soapenv:Body>
</soapenv:Envelope>

OUTPUT WSDL(从SoapUI映射):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <ns1:getBankResponse xmlns:ns1="http://thomas-bayer.com/blz/">
         <ns1:details>
            <ns1:bezeichnung>Bundesbank</ns1:bezeichnung>
            <ns1:bic>MARKDEF1100</ns1:bic>
            <ns1:ort>Berlin</ns1:ort>
            <ns1:plz>10591</ns1:plz>
         </ns1:details>
      </ns1:getBankResponse>
   </soapenv:Body>
</soapenv:Envelope>

1 个答案:

答案 0 :(得分:1)

没有&#39; CheckSomething&#39;您提供的WSDL中的方法。然而,有一个&#39; getBank&#39;你应该打电话的方法。例如:

 try {
 $soapClient = new SoapClient("http://www.thomas-bayer.com/axis2/services/BLZService?wsdl",array('trace' => 1,'exceptions' => true));
 $blz_param = array (
   'blz' => "10000000",
 );
 $info = $soapClient->getBank($blz_param);
 var_dump($info);
} catch (Exception $e) {
  var_dump($e ->getMessage());
}