How to make a PHP SOAP call using the SoapClient class

后端 未结 12 723
星月不相逢
星月不相逢 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:58

    I had the same issue, but I just wrapped the arguments like this and it works now.

        $args = array();
        $args['Header'] = array(
            'CustomerCode' => 'dsadsad',
            'Language' => 'fdsfasdf'
        );
        $args['RequestObject'] = $whatever;
    
        // this was the catch, double array with "Request"
        $response = $this->client->__soapCall($name, array(array( 'Request' => $args )));
    

    Using this function:

     print_r($this->client->__getLastRequest());
    

    You can see the Request XML whether it's changing or not depending on your arguments.

    Use [ trace = 1, exceptions = 0 ] in SoapClient options.

提交回复
热议问题