SoapServer发送text / html标头而不是text / xml

时间:2012-03-19 13:10:45

标签: php soapserver

我的soap服务器在响应头中发送Content-Type:text / html。我需要Content-type:text / 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; expires = Mon,19-Mar-2012 16:17:10 GMT;路径= /
P3P:CP =" NOI ADM DEV PSAi COM NAV OUR STP IND DEM"
变化:接受编码
内容编码:gzip
内容长度:877
内容类型: text / html ;字符集= UTF-8

我尝试使用text / xml conent type

调用header()
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之前和之后,但没有结果。

1 个答案:

答案 0 :(得分:1)

(在问题编辑中回答。转换为社区维基回答。请参阅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');
}