如何使用SoapClient在WSDL中调用方法

问题描述 投票:0回答:1

我遇到了SOAP的问题,我100%确定它是在我的最终而不是Web服务。

我可以成功连接到wsdl。

$wsdl="http://webservices_qa.linksunlimited.com/LinksWebService.svc?wsdl";
$client = new SoapClient($wsdl, array('trace'=>1));
$functions = $client->__getFunctions();
var_dump($functions);

向我展示功能,所以我知道我可以实现它。

ini_set('default_socket_timeout', 2000000);

$wsdl="http://webservices_qa.linksunlimited.com/LinksWebService.svc?wsdl";

$client = new SoapClient($wsdl, array('trace'=>1));
$result = $client->GetProductCatalog((object)$links_credentials);
//$result = $client->GetProductCatalog($links_credentials); 
//$client->__soapCall("GetProductCatalog", $links_credentials);
//$result = $client->__soapCall("GetProductCatalog", (object)$links_credentials); //when i try this i get null

我应该期待一个大的响应,大约1.6MB。

我收到:由于内部错误,服务器无法处理请求。有关错误的更多信息,请在服务器上启用IncludeExceptionDetailInFaults(来自ServiceBehaviorAttribute或配置行为),以便将异常信息发送回客户端,或者根据Microsoft .NET Framework SDK文档打开跟踪,检查服务器跟踪日志。

编辑:当我尝试

$result = $client->__soapCall("GetProductCatalog",$links_credentials);

我得到“格式化程序在尝试反序列化消息时抛出异常:对操作'GetProductCatalog'反序列化请求消息体时出错。从命名空间'http://schemas.xmlsoap.org/soap/envelope/'结束元素'Body'预期。从命名空间''找到元素'param1'。第2行,第158号位置。“

我觉得我很亲近......

php soap soap-client
1个回答
0
投票

好的问题是参数需要是多维的。所以最终看起来像

$result = $client->GetProductCatalog(array('requestCredentials'=>array('UserKey'=>$user, 'UserPassword'=>$pass)));
print_r($result->GetProductCatalogResult);

这在他们的文档中根本不明显。

© www.soinside.com 2019 - 2024. All rights reserved.