简体   繁体   中英

Consuming a .net Web Service with php and complex types

I am trying to call a web service which is expecting a complex type.. I did some research and found this is a big issue in php... maybe somebody has some tips?

Doing basic Soap requests work fine, such as

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

However, for updating, it is expecting a Client object... I already tried different things such as

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

Can anyone suggest me how to acomplish this?

Thanks.

I'd suggest trying SoapVar class. It allows you to specify the type name, etc. Example usage from the manual:

 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"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM