Performs a SOAP request

@see SoapClient class
426316
public function __doRequest($request, $location, $action, $version, $one_way = 0)
    {
        for ($attempt = 1; $attempt <= $this->connect_attempts; $attempt++) {

            $ch = curl_init($location);

            if ($ch === false) {
                throw new RuntimeException('cURL initialisation failed');
            }

            $curl_options = $this->curl_options;

            $curl_options[CURLOPT_RETURNTRANSFER] = true;
            $curl_options[CURLOPT_POST] = true;
            $curl_options[CURLOPT_POSTFIELDS] = $request;
            $curl_options[CURLOPT_HTTPHEADER] = array(
                sprintf('Content-Type: %s', $version == 2 ? 'application/soap+xml' : 'text/xml'),
                sprintf('SOAPAction: %s', $action)
            );
            $curl_options[CURLOPT_HEADER] = false; //Don't include the header in the body output
            $curl_options[CURLOPT_NOSIGNAL] = true; //http://www.php.net/manual/en/function.curl-setopt.php#104597

            if (curl_setopt_array($ch, $curl_options) === false) {
                throw new RuntimeException('Failed setting curl options');
            }

            $response = curl_exec($ch);
            $errno = curl_errno($ch);
            $error = curl_error($ch);
            curl_close($ch);

            if ($errno !== 0) {
                if ($attempt >= $this->connect_attempts) {
                    throw new ClientException("cURL connection error after ".$this->connect_attempts." attempts. Last error: " . $error);
                }
            } else {
                break; //Success
            }
        }

        if (!$one_way) {
            return $response;
        }
    }
1327831
def send_using_soap(self, request, destination, headers=None, sign=False):
        

        # _response = self.server.post(soap_message, headers, path=path)
        try:
            args = self.use_soap(request, destination, headers, sign)
            args["headers"] = dict(args["headers"])
            response = self.send(**args)
        except Exception as exc:
            logger.info("HTTPClient exception: %s", exc)
            raise

        if response.status_code == 200:
            logger.info("SOAP response: %s", response.text)
            return response
        else:
            raise HTTPError("%d:%s" % (response.status_code, response.content))
166860
public function setupClient()
    {
        /* Return if already set */
        if ($this->client)
            return $this;

        /* Set the options for the SOAP request */
        $sslContext = array(
            'ssl' => array(
                'allow_self_signed' => false,
                'verify_peer' => false /* Temporary fix */
            )
        );

        $soapArguments = array(
            'location' => $this->service,
            'encoding' => 'UTF-8',
            'cache_wsdl' => 'WSDL_CACHE_NONE',
            'stream_context' => stream_context_create($sslContext)
        );

        /* Start a new client */
        $this->client = new SoapClient($this->service, $soapArguments);

        /* Client configuration */
        $this->client->soap_defencoding = "utf-8";

        return $this;
    }
180532
def do_POST(self):
        '''
        '''
        global _contexts

        soapAction = self.headers.getheader('SOAPAction')
        post = self.path
        if not post:
            raise PostNotSpecified, 'HTTP POST not specified in request'
        if soapAction:
            soapAction = soapAction.strip('\'"')
        post = post.strip('\'"')
        try:
            ct = self.headers['content-type']
            if ct.startswith('multipart/'):
                cid = resolvers.MIMEResolver(ct, self.rfile)
                xml = cid.GetSOAPPart()
                ps = ParsedSoap(xml, resolver=cid.Resolve, readerclass=DomletteReader)
            else:
                length = int(self.headers['content-length'])
                ps = ParsedSoap(self.rfile.read(length), readerclass=DomletteReader)
        except ParseException, e:
            self.send_fault(FaultFromZSIException(e))
        except Exception, e:
            # Faulted while processing; assume it's in the header.
            self.send_fault(FaultFromException(e, 1, sys.exc_info()[2]))
        else:
            # Keep track of calls
            thread_id = thread.get_ident()
            _contexts[thread_id] = SOAPContext(self.server, xml, ps,
                                               self.connection,
                                               self.headers, soapAction)

            try:
                _Dispatch(ps, self.server, self.send_xml, self.send_fault,
                    post=post, action=soapAction)
            except Exception, e:
                self.send_fault(FaultFromException(e, 0, sys.exc_info()[2]))

            # Clean up after the call
            if _contexts.has_key(thread_id):
                del _contexts[thread_id]
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
348505
public SoapClientResponseActionBuilder receive() {
        SoapClientResponseActionBuilder soapClientResponseActionBuilder;
        if (soapClient != null) {
            soapClientResponseActionBuilder = new SoapClientResponseActionBuilder(action, soapClient);
        } else {
            soapClientResponseActionBuilder = new SoapClientResponseActionBuilder(action, soapClientUri);
        }

        soapClientResponseActionBuilder.withApplicationContext(applicationContext);

        return soapClientResponseActionBuilder;
    }
1300649
protected function performSoapRequest($function, $params)
  {
    if (true ===  $this->requestConfig['requestDelay']) {
      sleep(1);
    }

    $soapClient = new SoapClient(
      $this->webserviceWsdl,
      array('exceptions' => 1)
    );

    $soapClient->__setLocation(str_replace(
      '%%COUNTRY%%',
      $this->responseConfig['country'],
      $this->webserviceEndpoint
    ));

    $soapClient->__setSoapHeaders($this->buildSoapHeader($function));

    return $soapClient->__soapCall($function, array($params));
  }
881959
public function run() 
	{
		if ($this->documentor) {
			$this->documentor->setMethodData( $this->methods );
		}
		$request_xml = file_get_contents( 'php://input' );
		if ( !$request_xml ) 
		{
			if ( ( $query = $_SERVER['QUERY_STRING'] ) 
				&& isset($this->wsdl[$query]) && $this->wsdl[$query] )
			{
				header('Content-type: text/xml');
				header('Access-Control-Allow-Origin: *');
				echo $this->wsdl[$query];
			}
			else if ( $this->documentor )
			{
				header('Content-type: text/html; charset=' . $this->outputOptions['encoding']);
				$this->documentor->handle( $this, $this->methods );
			}
			else
			{
				// FIXME: add check for json-rpc protocol, if set and none of the xml protocols are set, use that
				header('Content-type: text/xml');
				header('Access-Control-Allow-Origin: *');
				echo xmlrpc_encode_request(
					null,  
					ripcord::fault( -1, 'No request xml found.' ),
					$this->outputOptions
				);
			}
		}
		else 
		{
			// FIXME: add check for the protocol of the request, could be json-rpc, then check if it is supported.
			header('Content-type: text/xml');
			header('Access-Control-Allow-Origin: *');
			echo $this->handle( $request_xml );
		}
	}
845387
public function sendMtUseSOAP()
    {
        if (empty($this->mtData)) {
            $this->error = TRUE;
            $result      = array(
                'status' => self::EXIT_CONFIG,
                'case'   => 'MT_DATA_IS_EMPTY',
                'desc'   => 'MT Data is Empty'
            );
            $this->logger->error(__FUNCTION__, 'MT Data is Empty', $result);
        } else {
            if ($this->isTest === TRUE) {
                // Test Service
                $this->logger->debug(__FUNCTION__, 'Test Send MT, giả lập quá trình gọi Request, chỉ test mã trả về');
                $request = array(
                    'status' => 0,
                    'code'   => 0,
                    'data'   => array(
                        'transId'     => $this->transactionId,
                        'username'    => $this->sdkConfig[self::SDP_CONFIG_KEY]['username'],
                        'description' => 'Test SOAP Services',
                        'status'      => self::SEND_MT_RESPONSE_STATUS_IS_SUCCESS
                    )
                );
            } else {
                // Create SOAP Object
                $soapRequest = self::createSOAPRequest();
                // WSDL Send Request
                $request = $soapRequest->setEndpoint(self::SEND_MT_SOAP_ENDPOINT)->setData($this->mtData)->setCallFunction(self::SEND_MT_SOAP_CALL_METHOD)->setFieldResult(self::SEND_MT_SOAP_FIELD_RESULT)->clientRequestSOAP();
                $this->logger->debug(__FUNCTION__, 'URL Endpoint => ' . json_encode(self::SEND_MT_SOAP_ENDPOINT));
                $this->logger->debug(__FUNCTION__, 'Data to request => ' . json_encode($this->mtData));
                $this->logger->debug(__FUNCTION__, 'Call Method => ' . json_encode(self::SEND_MT_SOAP_CALL_METHOD));
                $this->logger->debug(__FUNCTION__, 'Field Result => ' . json_encode(self::SEND_MT_SOAP_FIELD_RESULT));
                $this->logger->debug(__FUNCTION__, 'Response from Request => ' . json_encode($request));
            }
            // filter Request
            if (is_array($request) && isset($request['status'])) {
                $request_response = array(
                    'status'        => isset($request['data']['status']) ? $request['data']['status'] : NULL,
                    'description'   => isset($request['data']['description']) ? $request['data']['description'] : NULL,
                    'transactionId' => isset($request['data']['transId']) ? $request['data']['transId'] : NULL,
                    'username'      => isset($request['data']['username']) ? $request['data']['username'] : NULL
                );
                if (($request['status'] == self::SEND_MT_RESPONSE_STATUS_IS_SUCCESS) && (isset($request['code']) && $request['code'] == self::SEND_MT_RESPONSE_STATUS_IS_SUCCESS)) {
                    // Send MT thành công
                    $result = array(
                        'status'           => self::EXIT_SUCCESS,
                        'case'             => 'SUCCESS',
                        'desc'             => 'Send MT is Success!',
                        'response'         => array(
                            // Main Data
                            'transactionId' => $this->transactionId,
                            'moId'          => $this->moId,
                            'phone_number'  => $this->transactionMsisdn,
                            'mt_message'    => $this->mtMsg
                        ),
                        'request_response' => $request_response
                    );
                    $this->logger->debug(__FUNCTION__, 'Send MT is Success => ', $result);
                } else {
                    // Send MT thất bại
                    $result = array(
                        'status'           => self::EXIT_ERROR,
                        'case'             => 'FALSE',
                        'desc'             => 'Send MT is Error!',
                        'response'         => array(
                            // Main Data
                            'transactionId' => $this->transactionId,
                            'moId'          => $this->moId,
                            'phone_number'  => $this->transactionMsisdn,
                            'mt_message'    => $this->mtMsg
                        ),
                        'request_response' => $request_response
                    );
                    $this->logger->error(__FUNCTION__, 'Send MT is Error => ', $request_response);
                    $this->logger->debug(__FUNCTION__, 'Send MT is Success => ', $result);
                }
            } else {
                // Request Lỗi
                $result = array(
                    'status' => self::EXIT_ERROR,
                    'case'   => 'CLIENT_SOAP_ERROR',
                    'desc'   => 'Missing Result from WSDL'
                );
                $this->logger->debug(__FUNCTION__, 'Missing Result from SOAP ', $result);
            }
            $this->mtRequestResponse   = $request;
            $this->mtTransactionStatus = $result['status'];
        }
        if ($this->responseIsObject === TRUE) {
            $result = Utils::arrayToObject($result);
        }
        $this->mtResult = $result;

        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);
    }
85368
protected function callSoapMethod($method)
    {
        $args = func_get_args();
        array_shift($args);

        LogHandler::log($args, LoggerInterface::LEVEL_INFO, 'request_object');

        try {
            $response = call_user_func_array([$this->getSoapClient(), $method], $args);
            LogHandler::log($response, LoggerInterface::LEVEL_INFO, 'response_object');
        } catch (\SoapFault $e) {
            LogHandler::log(
                'SOAP ERROR (' . $e->faultcode . '): ' . $e->getMessage(),
                LoggerInterface::LEVEL_ERROR,
                'error'
            );
            throw new \SoapFault($e->faultcode, $e->faultstring);
        }

        $this->validateResponseCertificate();

        LogHandler::log(
            "Response certificate validated successfully",
            LoggerInterface::LEVEL_INFO,
            'response_certificate_validated'
        );

        return $response;
    }
1266593
function doRequest($action, $params = [], $config = []) {
    $this->request_input = ['action' => $action, 'parameters' => $params];

    return $this->getSoapClient($config)->__soapCall($action, [$params]);
  }
16377
public function run()
	{
		header('Content-Type: text/xml;charset='.$this->encoding);
		if(YII_DEBUG)
			ini_set("soap.wsdl_cache_enabled",0);
		$server=new SoapServer($this->wsdlUrl,$this->getOptions());
		Yii::app()->attachEventHandler('onError',array($this,'handleError'));
		try
		{
			if($this->persistence!==null)
				$server->setPersistence($this->persistence);
			if(is_string($this->provider))
				$provider=Yii::createComponent($this->provider);
			else
				$provider=$this->provider;

			if(method_exists($server,'setObject'))
			{
				if (is_array($this->generatorConfig) && isset($this->generatorConfig['bindingStyle'])
					&& $this->generatorConfig['bindingStyle']==='document')
				{
					$server->setObject(new CDocumentSoapObjectWrapper($provider));
				}
				else
				{
					$server->setObject($provider);
				}
			}
			else
			{
				if (is_array($this->generatorConfig) && isset($this->generatorConfig['bindingStyle'])
					&& $this->generatorConfig['bindingStyle']==='document')
				{
					$server->setClass('CDocumentSoapObjectWrapper',$provider);
				}
				else
				{
					$server->setClass('CSoapObjectWrapper',$provider);
				}
			}

			if($provider instanceof IWebServiceProvider)
			{
				if($provider->beforeWebMethod($this))
				{
					$server->handle();
					$provider->afterWebMethod($this);
				}
			}
			else
				$server->handle();
		}
		catch(Exception $e)
		{
			if($e->getCode()!==self::SOAP_ERROR) // non-PHP error
			{
				// only log for non-PHP-error case because application's error handler already logs it
				// php <5.2 doesn't support string conversion auto-magically
				Yii::log($e->__toString(),CLogger::LEVEL_ERROR,'application');
			}
			$message=$e->getMessage();
			if(YII_DEBUG)
				$message.=' ('.$e->getFile().':'.$e->getLine().")\n".$e->getTraceAsString();

			// We need to end application explicitly because of
			// http://bugs.php.net/bug.php?id=49513
			Yii::app()->onEndRequest(new CEvent($this));
			$server->fault(get_class($e),$message);
			exit(1);
		}
	}
394358
private function buildSoapClient() {
		$header = $this->buildAuthHeader();

		if($this->isTest())
			$location = self::DHL_SANDBOX_URL;
		else
			$location = self::DHL_PRODUCTION_URL;

		$auth_params = array(
			'login' => $this->getCredentials()->getApiUser(),
			'password' => $this->getCredentials()->getApiPassword(),
			'location' => $location,
			'trace' => 1
		);

		$this->setSoapClient(new SoapClient($this->getAPIUrl(), $auth_params));
		$this->getSoapClient()->__setSoapHeaders($header);
	}
1094307
def request(self, method, url, params=None, data=None, headers=None, auth=None,
                timeout=None, allow_redirects=False):
        
        raise TwilioException('HttpClient is an abstract class')
1110473
public function buildCurlClient()
    {
        //
        // Use PHP Native cURL because the various Soap clients (BeSimple,
        // PHP native SoapClient) can't handle the WSDL file.
        //
        $this->curl = curl_init($this->getEndPoint());

        $sslCertificate = $this->getSslCertificate();
        $sslKey         = $this->getSslKey();
        $sslKeyPassword = $this->getSslKeyPassword();
        $userName       = $this->getUsername();
        $password       = $this->getPassword();
        $headers        = $this->getHeaders();

        // configuring cURL not to verify the server certificate
        curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, 0);

        // setting the path where cURL can find the client certificate
        curl_setopt($this->curl, CURLOPT_SSLCERT, $sslCertificate);

        // setting the path where cURL can find the client certificate’s
        // private key
        curl_setopt($this->curl, CURLOPT_SSLKEY, $sslKey);

        // setting the key password
        curl_setopt($this->curl, CURLOPT_SSLKEYPASSWD, $sslKeyPassword);

        // setting the request type to POST
        curl_setopt($this->curl, CURLOPT_POST, 1);

        // setting the content type
        curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers);

        // setting the authorization method to BASIC
        curl_setopt($this->curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

        // supplying your credentials
        curl_setopt($this->curl, CURLOPT_USERPWD, $userName . ':' . $password);

        // telling cURL to return the HTTP response body as operation result
        // value when calling curl_exec
        curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1);

        return $this->curl;
    }
1230394
public function build()
    {
        $soapClient = (new Factory)->getClient($this->getEndpoint(), $this->getSoapOptions());

        $params['user_id'] = $this->userId;
        $params['agent_code'] = $this->agentCode;
        $params['agent_seq'] = $this->agentSeq;
        $client = new $this->client($soapClient, $params);

        if ($this->log) {
            //
        }

        return $client;
    }