Ejemplo n.º 1
0
 /**
  * NB: this assumes we're sending a ggRESTRequest
  * @param ggRESTRequest $request
  * @return ggRESTResponse
  * @todo do not error if we're sending a plain request? (test if methods exist)
  */
 function send($request)
 {
     if ($this->Verb != '') {
         $request->setMethod($this->Verb);
     }
     // use strict comparison, so that setting it to '' by the end user will work
     if ($this->NameVar !== null) {
         $request->setNameVar($this->NameVar);
     }
     if ($this->ResponseType !== null) {
         $request->setResponseType($this->ResponseType);
     }
     if ($this->RequestType !== null) {
         $request->setContentType($this->RequestType);
     }
     if ($this->Accept !== null) {
         $request->setAccept($this->Accept);
     }
     if (count($this->RequestHeaders)) {
         foreach ($this->RequestHeaders as $name => $value) {
             $request->setExtraHeader($name, $value);
         }
     }
     return parent::send($request);
 }
Ejemplo n.º 2
0
 /**
  * Sends a soap message and returns the response object.
  * NB: we define extra headers here and not in request obj because here we
  *     switch between soap 1.1 and 1.2 protocols in the client - but we need
  *     the request's name+ns for creating the soap 1.1 header...
  *     This could be probably be pushed down unto the request anyway
  * @param ggSOAPRequest $request
  * @return ggSOAPResponse
  * @todo raise an error if the request is not a soap one and has no ->ns() method
  */
 function send($request)
 {
     if ($this->SoapVersion != 0) {
         $request->setSOAPVersion($this->SoapVersion);
     }
     return parent::send($request);
 }
Ejemplo n.º 3
0
 function _send($request, $location, $action, $version, $one_way = 0)
 {
     if ($this->Wsdl != null) {
         /// patch temporarily Server, Path, Port using $location (needed in wsdl mode)
         $server = $this->Server;
         $path = $this->Path;
         $port = $this->Port;
         $protocol = $this->Protocol;
         $parsed = parse_url($location);
         $this->Server = $parsed['host'];
         $this->Path = $parsed['path'];
         $this->Port = isset($parsed['port']) ? $parsed['port'] : (@$parsed['scheme'] == 'https' ? 443 : 80);
         $this->Protocol = isset($parsed['scheme']) ? $parsed['scheme'] : (@$parsed['port'] == 443 ? 'https' : 'http');
     }
     $response = parent::send($request);
     if ($this->Wsdl != null) {
         $this->Server = $server;
         $this->Path = $path;
         $this->Port = $port;
         $this->Protocol = $protocol;
     }
     if (is_object($response)) {
         if (!$response->isFault()) {
             return $response->value();
         } else {
             // copy into our members the error codes, so that we can recover them
             // later while finishing the send() call
             $this->errorNumber = $response->FaultCode();
             $this->errorString = $response->FaultString();
             return $response->FaultCode() . ' ' . $response->FaultString();
         }
     } else {
         return $this->errorNumber() . ' ' . $this->errorString();
     }
 }
/**
 * Sample xmlrpc client that uses the ggws classes outside of an eZ Publish context
 * The server endpoint in use is the public one of the phpxmlrpc.sourceforge.net lib
 *
 * @author Gaetano Giunta
 * @copyright (c) 2010-2016 G. Giunta
 * @license code licensed under the GNU GPL. See LICENSE file
 */
// include client classes (this is done by autload when within an eZP context)
include_once "ggwebservices/classes/ggwebservicesclient.php";
include_once "ggwebservices/classes/ggwebservicesrequest.php";
include_once "ggwebservices/classes/ggxmlrpcrequest.php";
include_once "ggwebservices/classes/ggwebservicesresponse.php";
include_once "ggwebservices/classes/ggxmlrpcresponse.php";
// create a new client
$client = new ggWebservicesClient("phpxmlrpc.sourceforge.net", "/server.php");
// define the request
$request = new ggXMLRPCRequest("examples.addtwo", array(44, 45));
// send the request to the server and fetch the response
$response = $client->send($request);
if (!$response) {
    print "<pre>Error: " . $client->errorNumber() . " - \"" . $client->errorString() . "\"";
} else {
    // check if the server returned a fault, if not print out the result
    if ($response->isFault()) {
        print "<pre>Fault: " . $response->faultCode() . " - \"" . $response->faultString() . "\"";
    } else {
        print "<pre>Returned value was: \"" . $response->value() . "\"";
    }
}