xml请求/响应zend框架
问题描述:
我将如何在zend框架mvc中实现以下内容?xml请求/响应zend框架
$Request = '<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Easytobook>
<Request target="test">
<Authentication username="test" password="test">
<Function>GetCityInfo</Function>
</Authentication>
<CityId>1</CityId>
</Request>
</Easytobook>
</soap:Body>
</soap:Envelope>';
$socket = @fsockopen("testnl.etbxml.com", 80, &$errno, &$errstr);
$ReqBody = "request=".$Request;
$HTTPHeader = "POST /webservice/server_v21.php HTTP/1.0\n";
$HTTPHeader .= "Host: testnl.etbxml.com \n";
$HTTPHeader .= "Content-Type: application/x-www-form-urlencoded\n";
$HTTPHeader .= "Connection: Close\n";
$HTTPHeader .= "Content-Length: " .strlen($ReqBody) ."\n\n";
$HTTPHeader .= $ReqBody;
fwrite($socket, $HTTPHeader);
$Result = '';
while (!feof($socket))
{
$Result.= fread($socket, 10240);
}
echo $Result;
答
像这样的事情可能做的伎俩:
$client = new Zend_Http_Client('http://testnl.etbxml.com/webservice/server_v21.php', array('httpversion' => Zend_Http_Client::HTTP_0));
$client->setParameterPost('request', $Request);
$response = $client->request('POST');
嗨,这是否也该响应是纯XML,没有HTTP或者工作?我试过这个,并且在zend_client_adaptor_socket读取函数中得到了超时错误 – cwhisperer 2012-09-19 13:29:34