使用php和复杂类型的.net Web服务

时间:2011-02-14 17:31:48

标签: php xml soap

我正在尝试调用一个期望复杂类型的Web服务..我做了一些研究,发现这是php中的一个大问题...也许有人有一些提示?

执行基本的Soap请求可以正常工作,例如

$client->GetClientById(array('ClientID'=>123');

然而,为了更新,它期待一个Client对象......我已经尝试过不同的东西,比如

$clientobj = $client->GetClientById(array('ClientID'=>123');
$client->UpdateClient($clientobj, $params); 

有谁能建议我如何完成这个?

感谢。

1 个答案:

答案 0 :(得分:1)

我建议尝试SoapVar课程。它允许您指定类型名称等。手册中的示例用法:

 class SOAPStruct {
     function SOAPStruct($s, $i, $f) 
     {
         $this->varString = $s;
          $this->varInt = $i;
          $this->varFloat = $f;
      }
  }
  $client = new SoapClient(null, array('location' => "http://localhost/soap.php",
                                 'uri' => "http://test-uri/"));
  $struct = new SOAPStruct('arg', 34, 325.325);
  $soapstruct = new SoapVar($struct, SOAP_ENC_OBJECT, "SOAPStruct", "http://soapinterop.org/xsd");
  $client->echoStruct(new SoapParam($soapstruct, "inputStruct"));