簡體   English   中英

PHP soap方法傳遞參數

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM