我正在尝试将这段代码放在一起,但没有运气。由于我是初学者,因此无法弄清楚失败的原因。
尝试去:
通过 SOAP 协议向服务器发送请求。首先参考以前的工作代码。
什么失败了?
我尝试提出请求,但没有弹出任何内容。没有什么好事发生。在没有发现任何错误的调试器上运行代码。
以前的工作代码:
<?php
$client = new SoapClient('http://xxxxxxx.xxxxxxx.pt/xxxxxxx.asmx?WSDL');
$function = 'EditClient';
$arguments= array('EditClient' => array(
'empresa' => 'xxxxx',
'password' => '********',
'cliente' => '19781978',
'nome' => 'Justiceiro',
'morada' => 'Avenida akolá',
'localidade' => 'Integral',
'codPostal' => '4000-100',
'pais' => 'portugal',
'telefone' => '253994257',
'fax' => '000000000',
'telemóvel' => '000000000',
'email' => 'email@email.pt',
'nif' => '000000000',
'contacto' => 'none',
));
$options = array('location' => 'http://xxxxxx.xxxxxxx.pt/xxxxxx.asmx?WSDL');
$result = $client->__soapCall($function, $arguments, $options);
echo 'Response: ';
print_r($result);
?>
我在做什么
到目前为止,这就是我所拥有的,似乎没有什么不合适的,但再一次,我对此很陌生。
<?php
class cliente{
private $data;
private $arguments;
private $function;
private $client;
private $result;
function editcliente(){
$this->data=array();
$this->arguments=array();
}
public function setData($d){
$this->data = $d;
}
public function validate(){
$options = array('location' => 'http://xxxxxx.xxxxxxx.pt/xxxxxx.asmx?WSDL');
$verifica = true;
foreach ($this->data as $campo) {
$this->data[$campo] = $_GET[$campo];
$arguments = array('EditCliente' => array(
'empresa' => 'xxxxxx',
'password' => '********',
'cliente' => ' ',
'nome' => ''.$this->data["fnome"].'',
'morada' => ''.$this->data["fmorada"].'',
'localidade' => ''.$this->data["flocalidade"].'',
'codPostal' => '4000-100',
'pais' => ''.$this->data["Portugal"].'',
'telefone' => 'vazio',
'fax' => 'vazio',
'telemóvel' => ''.$this->data["ftelemovel"].'',
'email' => ''.$this->data["femail"].'',
'nif' => ''.$this->data["fnif"].'',
'contacto' => ''.$this->data["empresa"].'',
));
}
}
}
public function getData(){
print_r($this->data);
print_r($this->arguments);
}
public function sendrequest(){
$client = new SoapClient('http://apimarvin.ponto25.pt/apimarvin.asmx?WSDL');
$function = 'EditCliente';
$result = $client->__soapCall($function, $arguments, $options);
}
}
$cliente = new cliente();
$campos = array('fnome','fmorada','flodalidade','fcodigopostal','ftelemovel','femail','fnif','fempresa');
$cliente->setData($campos);
echo ($cliente->validate($data));
echo ($cliente->getData($data));
$cliente->sendrequest($data);
?>