2

I have a very simple web service that returns a string (hardcoded at that). I keep getting an error while parsing SOAP payload : Reserved XML Name.

I can view the WSDL no problem (interal/behind firewall, so no link to provide).

Here's a partial dump of the NuSOAP client after having called my method:

public 'request' => string 'POST myinternalhost.ca/ws.php HTTP/1.0
Host: myinternalhost.ca:443
User-Agent: NuSOAP/0.7.3 (1.114)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: ""
Content-Length: 510

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="htt'... (length=716)

public 'response' => string 'HTTP/1.1 200 OK
Date: Tue, 19 Jun 2012 18:43:10 GMT
Server: Apache/2.0.59 (Win32) DAV/2 mod_ssl/2.0.59 OpenSSL/0.9.8e mod_auth_sspi/1.0.4 PHP/5.2.3
X-Powered-By: PHP/5.2.3
X-SOAP-Server: NuSOAP/0.7.3 (1.114)
Content-Length: 470
Connection: close
Content-Type: text/xml; charset=ISO-8859-1

     <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-i'... (length=769)

  public 'responseData' => string '  <?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:vms_ws_list_filesResponse xmlns:ns1="http://tempuri.org"><return xsi:type="xsd:string">SomeText</return></ns1:vms_ws_list_filesResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>' (length=470)

public 'error_str' => string 'XML error parsing SOAP payload on line 1: Reserved XML Name' (length=59)

In the SOAP body, you can see "SomeText" which is the hard coded content that is returned from my web service that contains only one method:

$server->register('vms_ws_list_files',
  array('password' => 'xsd:string'),      // Password check
  array('return' => 'xsd:string'),     // Output parameters
    $ns,                                  // namespace
    $ns . '#vms_ws_list_files',                 // soapaction
    'rpc',                                // style
    'encoded',                            // use
    'Get list of files on disk'                       // documentation
  );

...

function vms_ws_list_files($password){
    global $site;
    // Check password
    if ($password != 'myHardCodedPwdForTesting') {
        return new soap_fault('Wrong password!', '', '');
    }
    $out = "SomeText";

    return $out;
}

In my case, port 443 isn't protected as it's internal/testing.

1

3 Answers 3

6

Remove the whitespace before <?xml and then it works. If you can't, maybe you can alter/extend the nusoap class to trim the response before interpretation. Most likely the extra whitespace comes from some accidental whitespace outside the <?php & ?> tags.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! As soon as I cleaned the whitepace and refreshed, it all worked flawlessly.
5

Adding the following line in nusoap.php :

$this->responseData = trim($this->responseData);

before this line :

return $this->parseResponse($http->incoming_headers, trim($this->responseData));

solved my same problem

Comments

1

In my code it was poorly formatted XML, as in the Portuguese language BR has very special characters, quotes, did not close the tag correctly. At the end of the code shows the return, an XML, made a check at this site: http://www.xmlvalidation.com/ then he went back to work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.