2009-06-23 53 views
2

我正在测试我的web空间上的服务器和客户机。使用Zend框架的SOAP服务器和客户机(正在出现错误)

当我尝试调用一个ServerMap类中定义一个简单的“TESTSERVER”功能,我得到 “看起来我们有没有XML文档”

..?

我在客户端调用了getFunctions,testServer是一个有效的函数。我尝试捕获所有异常,然后调用__getLastResponseHeaders()和__getLastResponse。

头:

string(348) "HTTP/1.1 200 OK 
Date: Tue, 23 Jun 2009 19:36:29 GMT 
Server: Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i PHP/5.2.9 
X-Powered-By: PHP/5.2.9 
Cache-Control: max-age=1 
Expires: Tue, 23 Jun 2009 19:36:30 GMT 
Vary: Accept-Encoding 
Content-Length: 1574 
Keep-Alive: timeout=5, max=100 
Connection: Keep-Alive 
Content-Type: text/html 
" 

响应:

string(1574) "DEBUG HEADER : This is a cached page ! 

" 

如果我看一下响应的HTML源文件,它实际上是:

string(1574) "DEBUG HEADER : This is a cached page !<?xml version="1.0"?> 
<A lot of xml that looks pretty much like my WSDL file that my Zend_Soap_AutoDiscover generates> 

所以怎么回事?我在网上搜索,我没有找到任何可靠的解决方案。 我没有空白空间在我之前..

回答

0

如果您输出到浏览器,它隐藏xml因为它在一个。浏览器会忽略它们不会下标的标签。

做一个echo htmlentities($ output);看到xml标签。

+0

这可能是真的,但我的问题仍然有效,我不要”不要从我的服务器上取回我想要的东西。我打印到浏览器的所有内容都来自__getLastResponse()等 – Roman 2009-06-23 20:08:19

0

不知道你的问题是什么,但我可以提供一些代码,我知道我们使用Zend Framework 1.8x作为Silverlight和WCF的后端SOAP服务。这项服务简单得2个整数,加上它们并返回结果。尽可能简单。

控制器类例如:

class SoapController extends Zend_Controller_Action { 

    /* 
    * SOAP server action 
    */ 
    public function indexAction() { 

     $request = $this->getRequest();  
     if ($request->getParam('wsdl') !== null) { 
      $wsdl = new Zend_Soap_AutoDiscover(); 
      $wsdl->setClass('SoapMath'); 
      $wsdl->handle(); 
     } 
     else { 
      $module = $request->getModuleName(); 
      $controller = $request->getControllerName(); 
      $uri = 'http://' . Zend_Registry::get('fullUrl') . '/' . $module . '/' . $controller . '?wsdl'; 
      $server = new Zend_Soap_Server($uri);  
      $server->setClass('SoapMath'); 
      $server->handle(); 
     } 
     exit; 
    } 
} 

和实际工作是由被定义为“SoapMath”做:

class SoapMath { 

    public function add($a,$b) { 

     return ($a + $b); 
    } 
}