我正在尝试使用 wsdl2php 在 PHP 中使用 Web 服务,但无法完成。生成的 Web 服务客户端代码和结果是:
class CreateProfile {
public $firstname;
public $email;
public $lastname;
public $mobile;
public $password;
public $provider;
public $uniqueID;
public $username;
}
class CreateProfileResponse {
public $CreateProfileResult;
}
class Profile_WebService extends SoapClient {
private static $classmap = array(
'CreateProfile' => 'CreateProfile',
'CreateProfileResponse' => 'CreateProfileResponse',
);
public function Profile_WebService($wsdl = "http://domain/wcfservice/Profile.WebService.asmx?WSDL", $options = array()) {
foreach(self::$classmap as $key => $value) {
if(!isset($options['classmap'][$key])) {
$options['classmap'][$key] = $value;
}
}
parent::__construct($wsdl, $options);
}
public function CreateProfile(CreateProfile $parameters) {
return $this->__soapCall('CreateProfile', array($parameters), array(
'uri' => 'http://domain/',
'soapaction' => ''
)
);
}
}
我想像这样使用它:
$client = new Profile_WebService();
$client->CreateProfile(array('provider' => 'ENERGIZER','username' => 'ENGtest1','password' => '1369','uniqueId' => '102030405062'));
但它一直在说:
PHP Catchable fatal error: Argument 1 passed to Profile_WebService::CreateProfile() must be an instance of CreateProfile, array given, called.
你能启发我吗?