如何使用SOAP1.2从WSDL文件中获取数据

时间:2015-04-24 09:43:33

标签: php web-services soap wsdl

我正在为一个项目工作,我必须从WSDL网址获取数据 的 http://80.127.98.91:6060/BonnenExterneApp?wsdl

我们的web服务使用SOAP1.2,我正在使用Nusoap0.9.5库来获取数据。但是我收到了像

这样的错误
RESULT = Array
(
    [faultcode] => e:VersionMismatch
    [faultstring] => received something that is not a SOAP Envelope
)

Constructor error

e:VersionMismatch: received something that is not a SOAP Envelope

我用来调用网络服务的代码是

<?php
require_once('lib/nusoap.php');

//Declare some paramaters for our soapclient. Need to make sure its set to soap 1.2
$params  = array("soap_version"=> SOAP_1_2,
                "trace"=>1,
                "exceptions"=>0,
                );


$iboks = new nusoap_client('http://80.127.98.91:6060/BonnenExterneApp?wsdl', $params);
$result = $iboks->call('AW_SYS01_01_Login', array("piUserId" => "myusername", "piPassword" => "mypassword"));

echo "<pre>RESULT = ".print_r($result, true)."</pre>";
$err = $iboks->getError();

if ($err) {
   echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
   exit();
}
?>

告诉我我做错了什么,我已经通过在线工具测试了这个网址。在线工具给出了答案,但我想从PHP获取数据。

我正在使用的工具是 的 http://soapclient.com/soaptest.html

出于安全原因,用户名和密码在此处更改。

提前致谢。

1 个答案:

答案 0 :(得分:0)

我得到了我的问题的答案。 URL仅作为示例,但我的确切网址现在也在使用。

我正在使用nusoap for wsdl1.2但是nusoap没有提供对wsdl1.2的支持所以我选择了PHP Soap Client。 的 http://php.net/manual/en/class.soapclient.php

我的代码现在看起来像

SqlConnection con = new SqlConnection();
    con.ConnectionString = "server=.;database=[Demo Database Nav (5-0)];user=us;password=id";

输出就像

<?php
$client = new SoapClient("http://www.webservicex.com/globalweather.asmx?wsdl", array('soap_version'   => SOAP_1_2));
$something =  $client->GetCitiesByCountry(array("CountryName"=>"India"));

echo "<pre>"; print_r($something);
die();
?>

我愿意和答案一样。

非常感谢,有人可能会从这篇文章中获得帮助。