It seems like a slight omission in the NuSOAP library ... it is assumed that the content headers MUST be "text / xml", so if your client tries to connect to a service that displays application / soap headers + xml, you will get errors, for example:
The answer is not text like / xml: application / soap + xml; encoding = UTF-8
To verify this, you can use the following small function template that I used to log in to the SOAP service. Remember, print the client object! In fact, you canβt get the result!
require_once('path/to/downloaded/libraries/nusoap.php'); var $endpoint = 'https://somedomain.com/path/to/soap/server/Login'; var $client; // the soapclient object function SOAP_Login() { $this->client = new soapclient($this->endpoint); $err = $this->client->getError(); if ($err) { // Display the error echo '<p><b>SOAP Constructor error: ' . $err . '</b></p>'; exit; // At this point, you know the call that follows will fail } $params = array( 'some' => 'thing.. depends on what the WSDL expects' ); $result = $this->client->call('someFunction', $params); print_r($result); // Without the fix, this prints nothing (ie false) !!! print_r($this->client); // Instead, look at the state of the client object, specifically error_str and debug_str }
When I printed my $ result, I didnβt get anything, but when I printed the $ client object, I could see that there were errors.
The little hack I implemented was in the nusoap.php file, around line 7500. Look at this if-statement:
if (!strstr($headers['content-type'], 'text/xml')) { $this->setError('Response not of type text/xml: ' . $headers['content-type']); return false; }
And change it to this:
if (!strstr($headers['content-type'], 'text/xml') && !strstr($headers['content-type'], 'application/soap+xml') ) { $this->setError('Response not of type text/xml: ' . $headers['content-type']); return false; }
All this allows NuSOAP to handle responses that invoke the header "application / soap + xml" (which is a valid xml header).