2013-10-10 139 views
-2

我試圖讓這段代碼在一起,但沒有運氣。由於我是初學者,無法弄清楚失敗的原因。爲什麼這個php類不工作?

嘗試:

發送請求到服務器通過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 protected]', 
         '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); 

?> 
+0

請問您是否可以用'borken'來重述您的問題。編碼沒有工作「,」當我這樣做時,我期望這個,而是發生這種情況?「或其他同樣具有建設性的東西? – AD7six

+0

謝謝你,試圖解釋代碼上發生了什麼。也許你現在可以閱讀理解。再次感謝你。永遠學習。 –

+1

看起來你還沒有通知。時間改變:http://stackoverflow.com/about –

回答

0

這是我如何調用PHP

一個SOAP功能在我的索引:

$client = new SoapClient('http://localhost:8100/PortalService.svc?wsdl'); 

然後:

$arguments = array('argument' => $arg); 
$response = $wcfclient->NameOfFunction($arguments); 

簡單明瞭。 希望這會幫助你。

+0

我想這是程序,但是課程本身有些失敗。我無法弄清楚什麼不符合規則。 謝謝Marijke的合作。會upvote,但還不能。 –