Question

I'm having a bit of a problem with nuSoap and IIS. The thing is that when calling a webservice i'm getting the following error.

XML error parsing SOAP payload on line 1: Mismatched tag

The same call in an Apache environment returns me a well formed XML, without additional characters at the start. Here's what it returns on IIS

*<?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="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:crearSolicitudResponse xmlns:ns1="http://localhost/EasyFlow/interfaces/webservices/"><respuesta xsi:type="xsd:string">EXITO: Solicitud 106 creada</respuesta></ns1:crearSolicitudResponse></SOAP-ENV:Body></SOAP-ENV:Envelo*

So what i'm seeing here is that IIS is generating the additional  before opening the XML and therefore truncating the last closing tag for the envelope. This is the request information and headers, and the response information and headers

**Request**

POST /EasyFlow/addons/webservices/CGWebservice.php HTTP/1.1
Host: 192.168.0.250:8081
User-Agent: NuSOAP/0.9.5 (1.123)
Connection: Keep-Alive
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: "http://localhost/EasyFlow/interfaces/webservices/crearSolicitud"
Content-Length: 892

<?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="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1595:crearSolicitud xmlns:ns1595="http://localhost/EasyFlow/interfaces/webservices/"><request_id xsi:type="xsd:string">106</request_id><request_name xsi:type="xsd:string">Solicitud de prueba WS</request_name><request_description xsi:type="xsd:string">Solicitud de prueba generada desde el WebService</request_description><request_createdby xsi:type="xsd:string">admin</request_createdby><tipo xsi:type="xsd:string">incop</tipo><monto xsi:type="xsd:string">1000</monto></ns1595:crearSolicitud></SOAP-ENV:Body></SOAP-ENV:Envelope>


**Response**

HTTP/1.1 200 OK
Date: Fri, 05 Jul 2013 16:15:02 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-Powered-By: PHP/5.4.15
Server: NuSOAP Server v0.9.5
X-SOAP-Server: NuSOAP/0.9.5 (1.123)
Content-Type: text/xml; charset=ISO-8859-1
Content-Length: 588

<?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="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:crearSolicitudResponse xmlns:ns1="http://localhost/EasyFlow/interfaces/webservices/"><respuesta xsi:type="xsd:string">EXITO: Solicitud 106 creada</respuesta></ns1:crearSolicitudResponse></SOAP-ENV:Body></SOAP-ENV:Envelo

If someone could help me with this it'd be awesome. I've been trying to fix this for over a week now.

Thanks

Was it helpful?

Solution

Finally found what's wrong!

The  characters were being generated in all of my php files server-wise, and this was because the encoding of the files was set to UTF-8 with BOM, which conflicted with IIS. I changed all of the files to UTF-8 without a BOM and the error was fixed

Used UTFCast to do it, in case anyone needs to do it in batch

OTHER TIPS

I had simillar problem, but no php files starts with BOM and seams no PHP code generate BOM. Maybe IIS add it?

So, I created ugly, but functional hack to NuSOAP - add some spaces to $payload:

file class.soap_server.php, bottom of send_response() function

...
            }
        }
        //end code

        // IIS hack 
        $payload .= "          ";
        // IIS hack

        $this->outgoing_headers[] = "Content-Length: ".strlen($payload);
        reset($this->outgoing_headers);
        foreach($this->outgoing_headers as $hdr){
            header($hdr, false);
        }
        print $payload;
        $this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
    }
    // end of send_response() function
...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top