简体   繁体   English

PHP soap方法传递参数

[英]PHP soap method pass parameter

I am new to SOAP and tryign to call webservice which is hosted on somewhereelse. 我是SOAP的新手,尝试尝试调用托管在其他地方的webservice。

I am trying to call "IsUniqueUser" webservice which check whether the user is unique or not. 我正在尝试调用“ IsUniqueUser” Web服务,该服务检查用户是否唯一。

Following is schema for service.. 以下是服务模式。

<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>

And i am trying to invoke this xervice in php using following code 我正在尝试使用以下代码在php中调用此xervice

  $client = new SoapClient('Some.wsdl');

And after http authentication i am trying to call the isUniqueUser Method and passed "userName" as parameter. 在HTTP身份验证之后,我尝试调用isUniqueUser方法并传递“ userName”作为参数。

 $unique = $client->__soapCall('isUniqueUser',  array('userName' =>'vish123'));

But nothing work out and i am getting following error 但是什么都没有解决,我得到以下错误

 stdClass Object
 (
[return] => stdClass Object
    (
        [errorCode] => 11ARPMWS1004
        [errorMessage] => null. null
        [status] => Failure
        [uniqueUser] => 
    )

)

I ahve tried to pass parameter in many ways like 我试图以多种方式传递参数,例如

    $params = array('UserName' =>$_POST['userName']);
    $unique = $client->__soapCall("isUniqueUser", $params);

OR 要么

    $unique = $client->isUniqueUser($params);

OR 要么

     $unique = $client->_soapCall('isUniqueUser', array('paramaters'=>$params));

OR 要么

       $unique = $client->_soapCall('isUniqueUser', array('request'=>$params));

And still i am getting the same error. 而且我仍然遇到相同的错误。 I have contacted with provider for this issue and they said there is something wrong with code while passing the parameter. 我已与提供商联系以解决此问题,他们说传递参数时代码有问题。

Can anyone please let me know how to fix this issue? 谁能让我知道如何解决此问题?

Thanks 谢谢

What I can see from you request is you have xsd:userName node under "ser:request", Can you try with creating array of request having array of userName. 我可以从您的请求中看到,您在“ ser:request”下有xsd:userName节点,您可以尝试创建具有userName数组的请求数组吗?

$params = array('UserName' =>$_POST['userName']);
$paramsrequest = array('request' =>$param);
$unique = $client->__soapCall("isUniqueUser",$paramsrequest);

see if this helps: 看看是否有帮助:

<?php
    $sClient = new SoapClient('Some.wsdl');
    $wrapper = null;
    $wrapper->isUniqueUser->request->userName = new SoapVar('SomeValidUserName', XSD_STRING);
    $result = $sClient->isUniqueUser($wrapper);
    echo $sClient->__getLastResponse();
?>

Also, have you tried to fire manually using some soap client like soapUI ? 另外,您是否尝试过使用soapUI之类的soap客户端手动触发? is it working? 工作正常吗?

In one of my project I use this : 在我的项目之一中,我使用了:

    $soapClient = new SoapClient($wsdl,$params);
    $reponseclient=$soapClient->authentification($username,$password);
    if($reponseclient->demandeRealisee===false){
         error_log("Couldn't log ".$username);
    }

I had the same problem. 我有同样的问题。 I tried everything you did. 我尝试了您所做的一切。

This one solved for me: 这个为我解决了:

 $result = $soapClient->somefunction(array( "param1" => "value1", "param2" => "value2" )); 

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

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