2012-03-19 80 views
0

我的soap服务器在响应头中发送Content-Type:text/html。我需要Content-type:text/xml。SoapServer发送文本/ html标题而不是文本/ xml

public function index() 
{ 
    $this->layout = 'soap'; 
    ini_set("soap.wsdl_cache_enabled", "0"); 
    $this->server = new SoapServer('wsdl/tur.wsdl', array(
      'soap_version' => SOAP_1_2, 
    )); 
    $this->server->setObject($this); 
    $this->server->handle(); 
} 

这里是服务器的响应:

HTTP/1.1 200 OK
日期:星期一,2012年3月19日12点17分10秒GMT
服务器:Apache/2.2.20(Ubuntu的)
X-Powered-By:PHP/5.3.6-13ubuntu3.6
Set-Cookie:CAKEPHP = msmid2fijgrj1efjs0otl8qfj1;到期=星期一,19-Mar-2012 16:17:10 GMT;路径=/
P3P:CP = “NOI ADM DEV PSAI COM NAV OUR OTRO STP IND DEM”
有所不同:接受编码
内容编码:gzip
的Content-Length:877
内容类型:text/html;字符集= UTF-8

我试图调用首部()用文本/ XML conent类型

public function index() 
{ 
    $this->layout = 'soap'; 
    ini_set("soap.wsdl_cache_enabled", "0"); 

    header("Content-Type: text/xml"); 

    $this->server = new SoapServer('wsdl/tur.wsdl', array(
     'soap_version' => SOAP_1_2, 
    )); 
    $this->server->setObject($this); 
    $this->server->handle(); 
} 

之前和构建SoapServer的后,但没有结果。

+0

决不此工作,但在documenation有'SoapServer的:: addSoapHeader'你尝试重写内容类型? – arma 2012-03-19 13:21:36

+0

根据对'handle'的doc的评论,“...'SoapServer :: handle();'方法向浏览器发送额外的HTTP头文件,其中之一是'Content-Type:application/soap + xml' “。不是一个真正的答案,但可能会提供一些见解。 – Travesty3 2012-03-19 13:27:37

回答

0

(。在一个问题回答的编辑转换为一个社区维基答案见Question with no answers, but issue solved in the comments (or extended in chat)

的OP写道:

解决,这是一个сakephp功能。由于How to write content type in cakephp?

public function index() 
{ 
    $this->layout = 'soap'; 
    ini_set("soap.wsdl_cache_enabled", "0"); 
    $this->server = new SoapServer('wsdl/tur.wsdl', array(
     'soap_version' => SOAP_1_2, 
    )); 
    $this->server->setObject($this); 
    $this->server->handle(); 

    $this->RequestHandler->respondAs('text/xml'); 
} 
相关问题