参数说明从PHP发送SOAP请求

时间:2014-01-17 22:44:43

标签: php soap

我正在运行以下代码:

<?php

// $wsdl = "http://www.restfulwebservices.net/wcf/StockQuoteService.svc?wsdl";
$wsdl = "http://clublinq.com/marylandlive/clublinq.svc?singleWSDL";

$client = new SoapClient($wsdl, array(
                        "trace"=>1,
                        "exceptions"=>0));

//    var_dump($client->__getFunctions()); 
//    var_dump($client->__getTypes()); 

//  $stock = "IBM";

// $parameters= array("request"=>$stock);
$parameters= array('KeyID'=>"1B3BFE04-78AF-4B84-967E-C32BA0B30FB0",'PlayerID'=>2588);
var_dump($parameters);
$value = $client->GetCustomerInfo(array('request' => array($parameters)));

// $value = $client->GetCustomerInfo(array('request' =>"1B3BFE04-78AF-4B84-967E-C32BA0B30FB0" ));
 var_dump($value);
 print "<pre>\n";
 print "<br />\n Request : ".htmlspecialchars($client->__getLastRequest());
 print "<br />\n Response: ".htmlspecialchars($client->__getLastResponse());
 print "</pre>";
?>      

使用Wireshark,我已确定我的请求是以null为参数发送的。

我哪里出错了?

3 个答案:

答案 0 :(得分:0)

将您的代码更改为:

$parameters= array('KeyID'=>"1B3BFE04-78AF-4B84-967E-C32BA0B30FB0",'PlayerID'=>2588);

$value = $client->GetCustomerInfo( $parameters );

如果有效,请不要忘记将其标记为正确

答案 1 :(得分:0)

这是另一个发送肥皂请求

$parameters= array('KeyID'=>"1B3BFE04-78AF-4B84-967E-C32BA0B30FB0",'PlayerID'=>2588);

$value = $client->__soapCall('GetCustomerInfo', array('parameters' => $parameters));

答案 2 :(得分:0)

此代码有效。

<?php
$client = new SoapClient("http://clublinq.com/marylandlive/clublinq.svc?singleWSDL",array(
                        "trace"=>1,
                        "exceptions"=>0)
);

$req->KeyID = "1B3BFE04-78AF-4B84-967E-C32BA0B30FB0";
$req->PlayerID="2588";
$parameters->request = $req;
$obj = $client->GetCustomerInfo($parameters);
print "<pre>\n";
print "<br />\n Request : ".htmlspecialchars($client->__getLastRequest());
print "<br />\n Response: ".htmlspecialchars($client->__getLastResponse());
print "</pre>";

>