[英]PHP soap method pass parameter
我是SOAP的新手,尝试尝试调用托管在其他地方的webservice。
我正在尝试调用“ IsUniqueUser” Web服务,该服务检查用户是否唯一。
以下是服务模式。
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="some service" xmlns:xsd="some xsd" xmlns:xsd1="">
<soap:Header/>
<soap:Body>
<ser:isUniqueUser>
<!--Optional:-->
<ser:request>
<xsd:userName>SomeValidUserName</xsd:userName>
</ser:request>
</ser:isUniqueUser>
</soap:Body>
</soap:Envelope>
我正在尝试使用以下代码在php中调用此xervice
$client = new SoapClient('Some.wsdl');
在HTTP身份验证之后,我尝试调用isUniqueUser方法并传递“ userName”作为参数。
$unique = $client->__soapCall('isUniqueUser', array('userName' =>'vish123'));
但是什么都没有解决,我得到以下错误
stdClass Object
(
[return] => stdClass Object
(
[errorCode] => 11ARPMWS1004
[errorMessage] => null. null
[status] => Failure
[uniqueUser] =>
)
)
我试图以多种方式传递参数,例如
$params = array('UserName' =>$_POST['userName']);
$unique = $client->__soapCall("isUniqueUser", $params);
要么
$unique = $client->isUniqueUser($params);
要么
$unique = $client->_soapCall('isUniqueUser', array('paramaters'=>$params));
要么
$unique = $client->_soapCall('isUniqueUser', array('request'=>$params));
而且我仍然遇到相同的错误。 我已与提供商联系以解决此问题,他们说传递参数时代码有问题。
谁能让我知道如何解决此问题?
谢谢
我可以从您的请求中看到,您在“ ser:request”下有xsd:userName节点,您可以尝试创建具有userName数组的请求数组吗?
$params = array('UserName' =>$_POST['userName']);
$paramsrequest = array('request' =>$param);
$unique = $client->__soapCall("isUniqueUser",$paramsrequest);
看看是否有帮助:
<?php
$sClient = new SoapClient('Some.wsdl');
$wrapper = null;
$wrapper->isUniqueUser->request->userName = new SoapVar('SomeValidUserName', XSD_STRING);
$result = $sClient->isUniqueUser($wrapper);
echo $sClient->__getLastResponse();
?>
另外,您是否尝试过使用soapUI之类的soap客户端手动触发? 工作正常吗?
在我的项目之一中,我使用了:
$soapClient = new SoapClient($wsdl,$params);
$reponseclient=$soapClient->authentification($username,$password);
if($reponseclient->demandeRealisee===false){
error_log("Couldn't log ".$username);
}
我有同样的问题。 我尝试了您所做的一切。
这个为我解决了:
$result = $soapClient->somefunction(array( "param1" => "value1", "param2" => "value2" ));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.