简体   繁体   English

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

[英]How to call a method in a WSDL using SoapClient

I am having an issue with SOAP and I am 100% sure it is on my end and not the web service. 我遇到了SOAP的问题,我100%确定它是在我的最终而不是Web服务。

I can connect to the wsdl successfully. 我可以成功连接到wsdl。

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

Shows me the functions so I know I can get to it. 向我展示功能,所以我知道我可以实现它。

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

I should expect a large response, about 1.6MB. 我应该期待一个大的响应,大约1.6MB。

I am getting: The server was unable to process the request due to an internal error. 我收到:由于内部错误,服务器无法处理请求。 For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs. 有关错误的更多信息,请在服务器上启用IncludeExceptionDetailInFaults(来自ServiceBehaviorAttribute或配置行为),以便将异常信息发送回客户端,或者根据Microsoft .NET Framework SDK文档启用跟踪和检查服务器跟踪日志。

EDIT: When I try 编辑:当我尝试

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

I get "The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'GetProductCatalog'. End element 'Body' from namespace ' http://schemas.xmlsoap.org/soap/envelope/ ' expected. Found element 'param1' from namespace ''. Line 2, position 158." 我得到“格式化程序在尝试反序列化消息时抛出异常:反序列化操作'GetProductCatalog'的请求消息体时出错。结束元素'Body'来自命名空间' http://schemas.xmlsoap.org/soap/envelope/ 'expect。从命名空间''找到元素'param1'。第2行,第158位。“

I feel like I am close.... 我觉得我很亲近......

Ok so the issue was that the parameters needed to be multi dimensional. 好的问题是参数需要是多维的。 so ultimately looks like 所以最终看起来像

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

This was not apparent at all in their documentation. 这在他们的文档中根本不明显。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM