How to make a PHP SOAP call using the SoapClient class

后端 未结 12 720
星月不相逢
星月不相逢 2020-11-22 17:28

I\'m used to writing PHP code, but do not often use Object-Oriented coding. I now need to interact with SOAP (as a client) and am not able to get the syntax right. I\'ve got

12条回答
  •  醉梦人生
    2020-11-22 17:53

    You need declare class Contract

    class Contract {
      public $id;
      public $name;
    }
    
    $contract = new Contract();
    $contract->id = 100;
    $contract->name = "John";
    
    $params = array(
      "Contact" => $contract,
      "description" => "Barrel of Oil",
      "amount" => 500,
    );
    

    or

    $params = array(
      $contract,
      "description" => "Barrel of Oil",
      "amount" => 500,
    );
    

    Then

    $response = $client->__soapCall("Function1", array("FirstFunction" => $params));
    

    or

    $response = $client->__soapCall("Function1", $params);
    

提交回复
热议问题