简体   繁体   English

PHP SoapServer:无法解析XML(WSDL文件)-没有XML文件-URL上带有“?wsdl”

[英]PHP SoapServer: doesn't resolve XML (WSDL file) - no XML file - with “?wsdl” on URL

I'm having problems with my Soap Server implemented on PHP on my production server (remote one). 我在生产服务器(远程服务器)上的PHP上实现的Soap Server出现问题。

I've implemented a simple Soap Server (native PHP class) with just on function on WSDL mode. 我已经实现了一个简单的Soap Server(原生PHP类),并且仅在WSDL模式下起作用。

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). 现在,如您所知,当您通过Web浏览器以“ http://localhost/soapserver/wsServer.php”之类的URL调用服务器时,您将得到一个空白页-就我而言-或您在那里编程的任何内容(服务器代码)。

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. 但是,如果您在“ http://localhost/soapserver/wsServer.php?wsdl”末尾使用“?wsdl”调用相同的URL,则服务器(我猜是句柄函数)会在网络浏览器上解析XML wsdl,因此您将获得text / xml内容类型,并且可以看到XML定义本身。

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. 我创建了一个Soap客户端来测试我自己的服务器,并查看它是否返回专家响应,并且一切正常。 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. Firefox在URL上显示“?wsdl”调用,典型错误是“ XML格式错误”,但是在这种特殊情况下,它是从一开始就出现的,就像根本没有XML文件一样。 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 SOAP错误:解析WSDL:无法从'http://.../SOAP_SERVER/seguimientoServer.php?wsdl'加载:预期开始标记,未找到'<'

I've correctly changed namespaces and URLs in the WSDL XML file. 我已经正确更改了WSDL XML文件中的名称空间和URL。 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... 我发现基于分块数据,内容长度,X-by-by等,存在与HTTP标头本身相关的错误。

But I don't see a solution. 但我看不到解决方案。

I've done a little hack on my server based on this (after handle() call): 我已经根据以下内容在服务器上做了一些改动(在handle()调用之后):

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... 但我敢肯定,这不一定是解决问题的方法...

looks like there is an invalid character at the beginning of your wsdl. wsdl的开头似乎有一个无效字符。 maybe a space? 也许是空间?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM