2012-03-19 77 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'); 
} 
相關問題