首页 文章

NUSOAP在IIS上生成其他字符

提问于
浏览
2

我对nuSoap和IIS有点问题 . 问题是,当调用web服务时,我收到以下错误 .

解析第1行上SOAP有效负载的XML错误:标记不匹配

在Apache环境中的相同调用返回一个格式良好的XML,一开始没有其他字符 . 这是它在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*

所以我在这里看到的是IIS在打开XML之前生成了额外的,因此截断了信封的最后一个结束标记 . 这是请求信息和 Headers ,以及响应信息和 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

如果有人可以帮助我,那就太棒了 . 我一直试图解决这个问题一个多星期了 .

谢谢

2 回答

  • 1

    终于找到了什么错!

    在服务器方面,我的所有php文件都生成了字符,这是因为文件的编码设置为带有BOM的UTF-8,与IIS冲突 . 我在没有BOM的情况下将所有文件更改为UTF-8,并修复了错误

    使用UTFCast执行此操作,以防任何人需要批量执行此操作

  • 0

    我有simillar问题,但没有php文件从BOM和接缝开始没有PHP代码生成BOM . 也许IIS添加它?

    所以,我为NuSOAP创建了丑陋但功能性的黑客 - 为$ payload添加了一些空格:

    file class.soap_server.php,send_response()函数的底部

    ...
                }
            }
            //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
    ...
    

相关问题