0

嗨,我目前在 linux 服务器上使用 PHP 来接收来自 Windows 服务器上托管的 WebService 的响应。

我正在使用以下 PHP 来读取响应:-

while (!feof($socket)) {
  $result .= fgets($socket, 4096);
}

fclose($socket);

if ($debug) echo '<pre>',$result,'</pre>';

显然,当我收到回复时,它的格式不正确,标签之间有断线,如下所示:-

/9j/4AAQSkZJRgABAQEAYABgAAD/4QBaRXhpZgAATU0AKgAAAAgABQMBAAUAAAABAAAASgMDAAEAAAABAAAAAFEQAAEAAAABAQAAAFERAAQAAAABAAAAAFESAAQAAAABAAAAAAAAAAAAAYagAACxj

代替这些:-

      </ResponseHdr><ResGetCustAreaSnapshot><cmc:GetCustAreaSnapshot xmlns:cmc="http://tnb.com.my/CGIS/D/cmc_customermgnt"><cmc:MAP_IMAGE_ZOOM1000>/9j/4AAQSkZJRgABAQEAYABgAAD/4QBaRXhpZgAATU0AKgAAAAgABQMBAAUAAAABAAAASgMDAAEAAAABAAAAAFEQAAEAAAABAQAAAFERAAQAAAABAAAAAFESAAQAAAABAAAAAAAAAAAAAYagAACxj//bAEMACAYGBwYFCAcHBwkJCAoMFA0MCwsMGRITDxQdGh8eHRocHCAkLicgIiwjHBwoNyksMDE0NDQfJzk9ODI8LjM0Mv/bAEMBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAp0DigMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+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AMIJ4P8A+hU0P/wXQ/8AxNH/AAgng/8A6FTQ/wDwXQ//ABNdBRQBxmqeCfCceoaKqeGNFVZL1lcLYRAMPs8xwfl5GQD9QK0/+EE8H/8AQqaH/wCC6H/4mrer/wDIT0H/AK/m/wDSaetWtanww9P1ZEd5ev6I5/8A4QTwf/0Kmh/+C6H/AOJqxY+E/DemXkd5YeH9KtLqPOyaCyjjdcgg4YAEZBI/GtiisizO03/j/wBY/wCvxf8A0RFTNS8NaDrNwtxqmiabfTqgRZLq1SVguScAsCcZJOPc0/Tf+P8A1j/r8X/0RFWjQBz/APwgng//AKFTQ/8AwXQ//E0f8IJ4P/6FTQ//AAXQ/wDxNdBRQBxmoeCfCZ1fSLeHwxooYyyTSothEA0SxMpJ+XkB5IuPUg44JGn/AMIJ4P8A+hU0P/wXQ/8AxNW7j/kbdO/68br/ANGW9ata1Phh6fqyI7y9f0Rz/wDwgng//oVND/8ABdD/APE1YsfCfhvTLyO8sPD+lWl1HnZNBZRxuuQQcMACMgkfjWxRWRZnQf8AIy33/Xnb/wDoc1aNZ0H/ACMt9/152/8A6HNWjQAUUUUAFZXhf/kUtG/68YP/AEWtatZXhf8A5FLRv+vGD/0Wtar+FL1X5Mh/GvR/oatFFFZFmdB/yMt9/wBedv8A+hzVo1nQf8jLff8AXnb/APoc1aNABRRRQBU1S9/s3Sb2/wDL8z7NA82zdjdtUnGe3SjS7L+zdJsrDzPM+zQJDv243bVAzjtnFVfFH/Ipaz/14z/+i2rVrV6Ul5t/glb82R9v5f1+QUUUVkWFccdVlW0uLC2LRFbq4M85VvkVrhwAAPmJJ4G35mPypzuaO/q2tlbcGLi3l4iZHIkuOQPkwCVQllG8ZY5ARSzoTzls832WFFHlYRX+0YAAVh5fmKqMTvfBRduOMRwfLmUduGwzmueW35nPWrcvurcybrRli1vR2sY8RWurJcXKZB8oyPDH1X50fe8

显然,即使从这里我也无法在不使用正确格式化它的代码块的情况下显示标签。

如果有人能指出我寻找解决此问题的正确方向,我将不胜感激。

谢谢你。

4

2 回答 2

0

尝试var_dump(htmlspecialchars($result))代替echo.

于 2012-07-13T13:09:40.590 回答
0

'你看看你的调试输出:在浏览器内还是在终端内?难道您只是通过在浏览器中将其可视化为 html 来将回复中的 xml 之类的标签(“<...>”)吞下吗?

如果不是这种情况,那么我会在较低级别检查回复的内容。使用 'tcpdump' 或 'wireshark' 转储实际内容,而不必依赖更高级别的输出。

于 2012-07-13T11:59:14.073 回答