示例#1
0
文件: Http.php 项目: zimbra-api/soap
 /**
  * Performs a SOAP request
  *
  * @param  Zimbra\Soap\Reques $request
  * @return object Soap response
  */
 public function doRequest(SoapRequest $request)
 {
     $this->soapMessage = new SoapMessage();
     if (!empty($this->_authToken)) {
         $this->soapMessage->addHeader('authToken', $this->_authToken);
     }
     if (!empty($this->_sessionId)) {
         $this->soapMessage->addHeader('sessionId', $this->_sessionId);
     }
     $isJs = false;
     if ($this->_format instanceof RequestFormat) {
         $this->soapMessage->addHeader('format', $this->_format->value());
         if ($this->_format->is(RequestFormat::JS())) {
             $isJs = true;
         }
     }
     $this->soapMessage->setRequest($request);
     $this->request = $isJs ? $this->soapMessage->toJson() : (string) $this->soapMessage;
     $response = $this->__doRequest($this->request, ['Content-Type' => $this->soapMessage->getContentType(), 'Method' => 'POST', 'User-Agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'PHP-Zimbra-Soap-API', 'SoapAction' => $request->getXmlNamespace() . '#' . $request->requestName()]);
     return new SoapResponse($response);
 }
示例#2
0
 public function testRequestFormat()
 {
     $values = array('xml', 'js');
     foreach ($values as $value) {
         $this->assertTrue(\Zimbra\Enum\RequestFormat::has($value));
     }
 }