2013-10-10 95 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,但还不能。 –