SoapFault Exception: [Client] SOAP-ERROR: Encoding: object has no 'user_name' property
SoapFault Exception: [Client] SOAP-ERROR: Encoding: object has no 'user_name' property
我在使用 PHP 发出 SoapClient 调用时遇到了一些问题,我收到了您在标题中看到的错误。
我很确定这是我遗漏的东西"small",但我检查了类似的问题,但没有找到我的问题的答案。
让我们直接看代码:
$client = new SoapClient("path_to_wsdl");
var_dump($client->__getFunctions()[1]);
var_dump($client->__getTypes()[73]);
//I need to call function in position [1], which is login, and I need to declare struct in position [73], user_auth
class user_auth {
function user_auth($username, $password) {
$this->user_name = $username;
$this->password = md5($password);
$this->version = 1;
}
}
$user = new user_auth("username", "password");
$params = array("user_auth" => $user);
print_r($params);
$response =$client->login(array($params)); //This is where I get the exception!
我从运行这个PHP得到的是:
字符串(70) "set_entry_result login(user_auth $user_auth, string $application_name)"
字符串(74) "struct user_auth { string user_name; string password; string version; }"
数组 ( [user_auth] => user_auth Object ( [user_name] => 用户名 [密码] => md5(密码) [版本] = > 1 ) )
所以错误是在 Object 中,我没有 "user_name" 字段,但看起来我有!
希望大家能给我一些帮助。
此致,
安德里亚
下面是如何解决的,看代码的区别:
$client = new SoapClient("path_to_wsdl");
class user_auth {
function user_auth($username, $password) {
$this->user_name = $username;
$this->password = md5($password);
$this->version = 1;
}
}
$user = new user_auth("username", "password");
$params = array($user);
$response =$client->__soapCall("login",$params); //Now working!
我在使用 PHP 发出 SoapClient 调用时遇到了一些问题,我收到了您在标题中看到的错误。
我很确定这是我遗漏的东西"small",但我检查了类似的问题,但没有找到我的问题的答案。
让我们直接看代码:
$client = new SoapClient("path_to_wsdl");
var_dump($client->__getFunctions()[1]);
var_dump($client->__getTypes()[73]);
//I need to call function in position [1], which is login, and I need to declare struct in position [73], user_auth
class user_auth {
function user_auth($username, $password) {
$this->user_name = $username;
$this->password = md5($password);
$this->version = 1;
}
}
$user = new user_auth("username", "password");
$params = array("user_auth" => $user);
print_r($params);
$response =$client->login(array($params)); //This is where I get the exception!
我从运行这个PHP得到的是:
字符串(70) "set_entry_result login(user_auth $user_auth, string $application_name)"
字符串(74) "struct user_auth { string user_name; string password; string version; }"
数组 ( [user_auth] => user_auth Object ( [user_name] => 用户名 [密码] => md5(密码) [版本] = > 1 ) )
所以错误是在 Object 中,我没有 "user_name" 字段,但看起来我有!
希望大家能给我一些帮助。
此致,
安德里亚
下面是如何解决的,看代码的区别:
$client = new SoapClient("path_to_wsdl");
class user_auth {
function user_auth($username, $password) {
$this->user_name = $username;
$this->password = md5($password);
$this->version = 1;
}
}
$user = new user_auth("username", "password");
$params = array($user);
$response =$client->__soapCall("login",$params); //Now working!