duanli0162 2011-11-11 12:19
浏览 75

PHP SoapServer:不解析XML(WSDL文件) - 没有XML文件 - 在URL上使用“?wsdl”

I'm having problems with my Soap Server implemented on PHP on my production server (remote one).

I've implemented a simple Soap Server (native PHP class) with just on function on WSDL mode.

So my code looks like:

ini_set("soap.wsdl_cache_enabled", "0");

$server = new SoapServer("wsSeguimiento.wsdl");

$server->addFunction("ResultadoDetalleExtendido");

$server->handle();

Now, as you know, when you call the server via web-browser with the url like "http://localhost/soapserver/wsServer.php", you got a blank page - in my case - or whatever you've programmed there (server code).

But if you call the same URL with the "?wsdl" at the end "http://localhost/soapserver/wsServer.php?wsdl", then the server (handle function I guess) resolves the XML wsdl on the web browser, so you get a text/xml content type and you can see the XML definition itself.

Now, it works on my development environment. No problems. I've created a Soap client to test my own server, and to see if it return the expeted response, and everything works fine. But when I upload the code to the production server, it doesn't work.

Firefox shows on the url with "?wsdl" call, the typical error saying "XML malformed", but in this particular case it's from the beginning, like if there were no XML file at all. And if I use my client, I get the error:

SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://.../SOAP_SERVER/seguimientoServer.php?wsdl' : Start tag expected, '<' not found

I've correctly changed namespaces and URLs in the WSDL XML file. So it have to work properly. But it doesn't.

I've found that there are existing bugs related with HTTP header itself, based on chunked data, content-length, X-powered-by, whatever...

But I don't see a solution.

I've done a little hack on my server based on this (after handle() call):

if( isset($_REQUEST['wsdl']) )
{
    ob_clean();
    echo file_get_contents( "wsSeguimiento.wsdl" );
}

And with this, it really works! But I'm sure that this doesn't have to be the way to solve it...

  • 写回答

1条回答 默认 最新

  • duanjiao6735 2011-11-11 12:49
    关注

    looks like there is an invalid character at the beginning of your wsdl. maybe a space?

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作