skip to Main Content

I want to call a soap API, to save data to Sage X3 version 12.
I’m using this code:

$options = array(
      'login' => $username,
      'password' => $password,
  );

  $api = parent::__construct($url, $options);
  $result = parent::__soapCall($function_name, $arguments, $options, $input_headers, $output_headers);
  return parent::__getLastResponse();

My PHP class extends SoapClient

I’m using basic auth with pre-emptive auth, but I get always an empty response.
Is there any problem in my code and why I get an empty response?

2

Answers


  1. You need to put the arguments in an extra array like so

    try {
        $result = parent::__soapCall($function_name, [$arguments], $options, $input_headers, $output_headers);
    } catch (SoapFault $exception) {
        echo $exception->getMessage();
    }
    

    If that does not work, check out for a SoapFault Exception and look into the error message.

    You also should have a look at the Client creation. Here you can put in the credentials for the WSDL and control in the options trace and exceptions. If you have it disabled, then enable it. Usually, it is enabled by default.

    Login or Signup to reply.
  2. The essence of the soap protocol is the http protocol. You can output the XML information you requested through a soap operation in PHP, then call this interface through postman, and put the xml content into postman to query the response results. Remember to set the raw option in postman. , the data format is xml. I have been troubleshooting this way before. I’m sorry that I didn’t record how PHP outputs the XML requested by soap, but I am sure it can be exported.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search