1

I'm trying to invoque this operation getCountries but I can't figure out reading the WSDL file wich parameters are needed and in which structured way:

http://webservice.nizacars.es/Rentway_WS/getCountries.asmx?WSDL

I've already tried with:

$this->soap_client->getCountries(
  array(
    'countriesRequest' => array(
      'companyCode' => $this->login,
      'allCountries' => true
     )
  )
)

$this->soap_client->getCountries(
  array(
      'companyCode' => $this->login,
      'allCountries' => true
  )
)


$this->soap_client->getCountries(
      'companyCode' => $this->login,
      'allCountries' => true
)    

But it seems I'm not matching the specs, since I'm getting a "[Server was unable to process request. ---> Object reference not set to an instance of an object.]"

The final request with SoapClient::__getLastRequest is:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.jimpisoft.pt/Rentway_Reservations_WS/getCountries">
<SOAP-ENV:Body>
<ns1:getCountries/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Edit, Solution:

$data = array(
                'getCountries' => array(
                    'objRequest' => array(
                        'companyCode' => $this->login,
                        'allCountries' => true
                    )
                )
            );
$result = @$this->_client->__call('getCountries',$data);
javier_domenech
  • 5,995
  • 6
  • 37
  • 59

1 Answers1

2

wich parameters are needed and in which structured way:

You can use the soapUI-tool for generating a valid soap-request and response.

I propose to compare your soap-request (by logging it) with the one generated by soapUI:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:get="http://www.jimpisoft.pt/Rentway_Reservations_WS/getCountries">
   <soap:Header/>
   <soap:Body>
      <get:getCountries>
         <!--Optional:-->
         <get:objRequest>
            <!--Optional:-->
            <get:companyCode>?</get:companyCode>
            <get:allCountries>?</get:allCountries>
         </get:objRequest>
      </get:getCountries>
   </soap:Body>
</soap:Envelope>
Aydin K.
  • 3,309
  • 36
  • 44
  • This is the output of SoapClient::__getLastRequest method: – javier_domenech Jan 31 '17 at 12:04
  • The output is not readable in the comment section, try to paste it into your original question/OP with the code-formatting tag. – Aydin K. Jan 31 '17 at 12:08
  • According to the example in: https://www.jimpisoft.pt/Rentway_Reservations_WS/getCountries.asmx?op=getCountries they expect at least the allCountries-element in the request (although your request is valid according to the wsdl). – Aydin K. Jan 31 '17 at 12:15
  • I know Aydin, but I don't know why, look at the things I tried, in any case, always returns the posted request – javier_domenech Jan 31 '17 at 12:19
  • Ok. I am not an expert in the soap_client of php, but the missing two parameters must be related to your implementation/code. Maybe http://stackoverflow.com/questions/11593623/how-to-make-a-php-soap-call-using-the-soapclient-class helps ? (especially the last answer at the bottom). – Aydin K. Jan 31 '17 at 12:24
  • I updated the solution following your advices, Thanks a lot mate, I was turning mad... I still don't know why calling the method directly does that weird stuff but I can't spend more time with this .. – javier_domenech Jan 31 '17 at 12:40