【发布时间】:2016-06-05 12:26:25
【问题描述】:
我想与 SOAP(作为客户端)进行交互,但无法获得正确的输入参数语法。我有一个 WSDL URL,我已经用 SoapUI 对其进行了测试,它正确地返回了结果。 WSDL 中定义了两个函数,但我只需要一个(下面的“FirstFunction”)。这是我为获取可用函数和类型信息而运行的脚本:
$client = new SoapClient("http://example.com/webservices?wsdl");
var_dump($client->__getFunctions());
var_dump($client->__getTypes());
这是它生成的输出:
array(
[0] => "FirstFunction Function1(FirstFunction $parameters)",
[1] => "SecondFunction Function2(SecondFunction $parameters)",
);
struct Amount {
anyURI Identifier;
Information charge;
string referenceCode;
}
struct Information {
string description;
decimal amount;
string code;
}
根据上述结果,我使用nusoap 和php 开发了我的客户端,如下所示:
class Information
{
public $description;
public $amount;
public $code;
}
class Amount {
public $Identifier;
public $charge;
public $referenceCode;
}
$charge = new Information();
$charge->description = "ROUTE=XXX|abc=".$code;
$charge->amount = "NULL";
$charge->code = $chargecode;
$params = new Amount();
$params->Identifier =$num;
$params->charge = $charge;
$params->referenceCode = $refcode;
$header = new SoapHeader('key', $key);
$client->__setSoapHeaders($header);
try
{
$res = $client->__call('charge',array('parametrs'=>$params));
print_r($res->return);
}
catch(PDOException $e)
{
print_r($e->getMessage());
}
我得到以下错误结果:
Uncaught SoapFault exception: [soapenv:Server] unknown
【问题讨论】:
标签: php soap struct wsdl nusoap