xml请求/响应zend框架

时间:2011-04-13 11:47:09

标签: zend-framework soap

我如何在zend框架mvc中实现以下功能?

$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;

1 个答案:

答案 0 :(得分:0)

这样的事情可能会起到作用:

$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');