Do a soap request
498753
def soap_action(self, service, action, payloadbody):
        """"""
        payload = self.soapenvelope.format(body=payloadbody).encode('utf-8')
        headers = {"Host": self.url,
                   "Content-Type": "text/xml; charset=UTF-8",
                   "Cache-Control": "no-cache",
                   "Content-Length": str(len(payload)),
                   "SOAPAction": action}
        try:
            response = self.session.post(
                url=self.url + service, headers=headers, data=payload)
        except Exception as exp:
            return False
        if response.status_code != 200:
            return False
        try:
            xdoc = xml.etree.ElementTree.fromstring(response.text)
        except xml.etree.ElementTree.ParseError:
            return False
        return xdoc
36797
public function run() {
        // We will probably need a lot of memory in some functions.
        raise_memory_limit(MEMORY_EXTRA);

        // Set some longer timeout since operations may need longer time to finish.
        external_api::set_timeout();

        // Set up exception handler.
        set_exception_handler(array($this, 'exception_handler'));

        // Init all properties from the request data.
        $this->parse_request();

        // Authenticate user, this has to be done after the request parsing. This also sets up $USER and $SESSION.
        $this->authenticate_user();

        // Make a list of all functions user is allowed to execute.
        $this->init_service_class();

        if ($this->wsdlmode) {
            // Generate the WSDL.
            $this->generate_wsdl();
        }

        // Log the web service request.
        $params = array(
            'other' => array(
                'function' => 'unknown'
            )
        );
        $event = \core\event\webservice_function_called::create($params);
        $logdataparams = array(SITEID, 'webservice_soap', '', '', $this->serviceclass . ' ' . getremoteaddr(), 0, $this->userid);
        $event->set_legacy_logdata($logdataparams);
        $event->trigger();

        // Handle the SOAP request.
        $this->handle();

        // Session cleanup.
        $this->session_cleanup();
        die;
    }
864234
def _request(self, url, method = u"get", data = None, headers=None, **kwargs):
        
        #        if self.access_token:
        #            auth_header = {
        #                u"Authorization": "Bearer %s" % (self.access_token)
        #            }
        #            headers.update(auth_header)
        #basic auth
        msg = "method: %s url:%s\nheaders:%s\ndata:%s" % (
            method, url, headers, data)
        #print msg
        if not self.use_oauth:
            auth = (self.sk_user, self.sk_pw)
            if not self.client:
                self.client = requests.session()
            r = self.client.request(method, url, headers=headers, data=data, auth=auth,**kwargs)
        else:
            if not self.client:
                self.client = requests.session(hooks={'pre_request': oauth_hook})
            r = self.client.request(method, url, headers=headers, data=data,**kwargs)
        return r
757151
def do_request(method, url, options = {})
      begin
        response = self.class.send(method, api_url(url), options)
        check_response_codes(response)
        response.parsed_response
      rescue Timeout::Error
        raise Unavailable.new('Service Unavailable')
      end
    end
1353866
public function execute()
    {
        try {
            // Note that when provided a non-existing WSDL, PHP will still generate an error in error_get_last()
            // https://github.com/bcosca/fatfree/issues/404
            // https://bugs.php.net/bug.php?id=65779

            // Prepare request
            $soapClient = $this->soapClient = new SoapClient($this->url, array(
                'trace' => $this->wei->isDebug()
            ));

            // Execute beforeExecute and beforeSend callbacks
            $this->beforeExecute && call_user_func($this->beforeExecute, $this, $soapClient);
            $this->beforeSend && call_user_func($this->beforeSend, $this, $soapClient);

            // Execute request
            $this->response = $soapClient->__soapCall($this->method, array($this->data));
        } catch (\SoapFault $e) {
            $soapClient = null;
            $this->errorException = $e;
        }

        // Trigger success, error and complete callbacks
        if (!$this->errorException) {
            $this->success && call_user_func($this->success, $this->response, $this, $soapClient);
        } else {
            $this->error && call_user_func($this->error, $this, $soapClient);
        }
        $this->complete && call_user_func($this->complete, $this, $soapClient);

        if ($this->throwException && $this->errorException) {
            throw $this->errorException;
        }

        return $this;
    }
964619
protected function applySoapHeaders()
    {
        $headers = $this->request->getHeaders() ?: [];

        if ($headers instanceof SoapHeader) {

            $headers = [ $headers ];

        } else {

            foreach ($headers as &$header) {
                if ($header instanceof SoapHeader) continue;

                $namespace      = isset($header['namespace']) ? $header['namespace'] : null;
                $name           = isset($header['name']) ? $header['name'] : null;
                $data           = isset($header['data']) ? $header['data'] : null;
                $mustUnderstand = isset($header['mustunderstand']) ? $header['mustunderstand'] : null;
                $actor          = isset($header['actor']) ? $header['actor'] : null;

                $header = new SoapHeader($namespace, $name, $data, $mustUnderstand, $actor);
            }
        }

        unset($header);

        $this->client->__setSoapHeaders($headers);
    }
871714
private function handleRequest()
    {
        //check if it's a legal webservice class
        if (!in_array($this->name, $this->classNameArr)) {
            throw new Exception('No valid webservice class.');
        }

        //check cache
        if (!file_exists($this->wsdlfile)) {
            $this->createWSDL();
        }

        $options = array('soap_version' => SOAP_1_1,
                         'actor' => $this->actor,
                         'classmap' => $this->structureMap, );

        header('Content-type: text/xml');
        $this->server = new SoapServer($this->wsdlfile, $options);
        $this->server->setClass($this->name);
        $this->server->setPersistence($this->persistence);

        use_soap_error_handler(true);
        $this->server->handle();
    }
189150
def send_key(self, key):
        """"""
        if isinstance(key, Keys):
            key = key.value
        params = '<X_KeyEvent>{}</X_KeyEvent>'.format(key)
        self.soap_request(URL_CONTROL_NRC, URN_REMOTE_CONTROL,
                          'X_SendKey', params)
208921
public function request($class, $service, $method, $arguments = [])
    {
        // Get WSDL URL
        $wsdl = $this->getWsdlUri($class);

        // Init SOAP client
        $this->client = new SoapClient($wsdl, [
            'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
            'trace' => true,
            'exceptions' => true,
            'cache_wsdl' => WSDL_CACHE_MEMORY,
        ]);

        // Add authentication to the query
        $request = $this->addAuthHeader($arguments);

        $result = $this->client->__soapcall($service, array($method => $request));

        if (!isset($result->ReturnValue)) {
            return;
        } else {
            // If more than one, return all return values
            if (is_array($result->ReturnValue) && count($result->ReturnValue) > 1) {
                return $result;
            } else {
                return $result->ReturnValue;
            }
        }
    }
185796
private function _googleSoap($query, $start=0, $max=10, $filter=false, $restrict="", $safe=false, $lr="", $ie="", $oe="")
	{
		$wsdl = new SOAP_WSDL('http://api.google.com/GoogleSearch.wsdl');
		$soapclient = $wsdl->getProxy();
		
		if (get_class($soapclient) != "SOAP_Fault")
		{
			$result = $soapclient->doGoogleSearch($this->Key,$query,$start,$max,$filter,$restrict,$safe,$lr,$ie,$oe);
		}
		else
		{
			throw new Exception("SOAP_Fault: " . $soapclient->message);
		}
		
		if (PEAR::isError($result)) 
		{
			throw new Exception("PEAR Exception: " . $result->message);
		}
		else 
		{
			return $result;
		}

	}
523293
def _request_internal(self, command, **kwargs):
        """"""
        args = dict(kwargs)
        if self.ssid:
            args['ssid'] = self.ssid
        method = getattr(self.api, command)
        response = method(**args)
        if response and 'status' in response:
            if response['status'] == 'error':
                raise SubregError(
                    message=response['error']['errormsg'],
                    major=response['error']['errorcode']['major'],
                    minor=response['error']['errorcode']['minor']
                )
            if response['status'] == 'ok':
                return response['data'] if 'data' in response else dict()
            raise Exception("Invalid status found in SOAP response")
        raise Exception('Invalid response')
1068981
private function soapCall(AbstractRequest $payload)
    {
        $request = $payload->getDocument();

        $envelope = $request->createElementNS('http://schemas.xmlsoap.org/soap/envelope/', 'SOAP-ENV:Envelope');
        $envelope->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:ns1', self::NAMESPACE_N1);
        $envelope->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:ns2', self::NAMESPACE_N2);
        $envelope->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:ns3', self::NAMESPACE_N3);

        $body = $request->createElement('SOAP-ENV:Body');
        $body->appendChild($payload->getElement());
        $envelope->appendChild($body);

        $request->appendChild($envelope);
        $xml = $request->saveXML();

        if ($this->debug) {
            var_dump($xml);
        }

        $response = $this->doRequest($xml);

        if ($this->debug) {
            var_dump($response);
        }

        if ($response === false) {
            throw new \Exception($this->getErrorMessage());
        }

        if (empty($response)) {
            throw new \Exception('Empty API response received');
        }

        $responseDoc = new \DOMDocument('1.0', 'UTF-8');
        $responseDoc->loadXML($response);

        $errorResponse = $this->checkForSoapFault($responseDoc);

        return $errorResponse !== null ? $errorResponse : $responseDoc;
    }
847581
public function __soapCall(
        $function_name,
        $arguments,
        $options = null,
        $input_headers = null,
        &$output_headers = null
    ) {
        $class = get_class($this);


        $service = strtr(substr($class, strrpos($class, '\\') + 1), ['ServiceService' => 'Service']);
        $this->__setCookie('timestamp', $timestamp = time());
        $this->__setCookie('nonce', $nonce = uniqid('', true));
        $this->__setCookie('signature', $this->urlEncode($this->sign(array_merge($arguments, [
            '__method' => $function_name,
            '__service' => $service,
            '__hostname' => $this->endpoint,
            '__timestamp' => $timestamp,
            '__nonce' => $nonce,

        ]))));
        return parent::__soapCall($function_name, $arguments, $options, $input_headers, $output_headers);
    }
216769
def invoke_soap(message_type, message)
      started = Time.now
      notification_payload = { request: message }

      response = client.call(message_type, message: message)
      handle_message_for_response(response)
      notification_payload[:response] = response.body
    rescue Excon::Errors::Timeout => raw_error
      notification_payload[:error] = handle_error(raw_error)
      raise TimeoutError
    rescue Excon::Errors::BadGateway => raw_error
      notification_payload[:error] = handle_error(raw_error)
      raise BadGatewayError
    rescue => raw_error
      processed_error = handle_error(raw_error)
      notification_payload[:error] = processed_error
      raise processed_error
    ensure
      publish("creditsafe.#{message_type}", started, Time.now,
              SecureRandom.hex(10), notification_payload)
    end
1254097
def build_request(method, options)
      builder  = underscore("build_#{method}")
      self.respond_to?(builder) ? self.send(builder, options) :
                                  soap_envelope(options).target!
    end
708758
function SOAPProcess(params) {
    RED.nodes.createNode(this, params);
    this.name = params.name;
    this.waitfor = params.waitfor;
    let node = this;
    this.on('input', function(msg) {
      if (msg.error) {
        // FIXME: Add error handling here
      } else {
        params.actionType = 'read';
        node.log('SOAPProcess');
        node.log(JSON.stringify(params));
        // node.log(JSON.stringify(msg));
        processSOAPNode(node, params, msg);
      }
    });
  }
503604
protected SoapCall<T> createSoapCall(Method soapClientMethod, Object[] args) {
    return new SoapCall<T>(soapClientMethod, soapClient, args);
  }