Makes SOAP request to google
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;
		}

	}
1368385
def soap_action(self, service, action, payloadbody):
        
        payload = self.soapenvelope.format(body=payloadbody).encode('utf-8')
        headers = ['SOAPAction: ' + action,
                   'Content-Type: application/soap+xml; charset=UTF-8',
                   'Content-Length: ' + str(len(payload))]

        try:
            curl = pycurl.Curl()
            curl.setopt(pycurl.SSL_CIPHER_LIST, "AES256-SHA")
            curl.setopt(pycurl.SSLVERSION, pycurl.SSLVERSION_TLSv1_0)
    #        self.curl.setopt(pycurl.CAINFO,'ihc.crt')
            curl.setopt(pycurl.SSL_VERIFYPEER, 0)
            curl.setopt(pycurl.SSL_VERIFYHOST, 0)
            curl.setopt(pycurl.POST, 1)
            curl.setopt(pycurl.HEADERFUNCTION, IHCCurlConnection._write_header)

            curl.setopt(pycurl.HTTPHEADER, headers)
            inbuffer = BytesIO(payload)
            curl.setopt(pycurl.READDATA, inbuffer)
            buffer = BytesIO()
            curl.setopt(pycurl.WRITEDATA, buffer)
            curl.setopt(pycurl.URL, self.url + service)
            curl.setopt(pycurl.COOKIE, IHCCurlConnection.cookies)
    #        curl.setopt(pycurl.VERBOSE,1)
            curl.perform()
            body = buffer.getvalue().decode('utf-8')
            code = curl.getinfo(pycurl.HTTP_CODE)
            curl.close()
        except Exception as exp:
            return False
        if code != 200:
            return False
        try:
            xdoc = xml.etree.ElementTree.fromstring(body)
        except xml.etree.ElementTree.ParseError:
            return False
        return xdoc
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;
            }
        }
    }
385239
function &sendPayloadCURL($msg, $server, $port, $timeout=0, $username='',
			$password='', $authtype=1, $cert='', $certpass='', $cacert='', $cacertdir='',
			$proxyhost='', $proxyport=0, $proxyusername='', $proxypassword='', $proxyauthtype=1, $method='https',
			$keepalive=false, $key='', $keypass='')
		{
			if(!function_exists('curl_init'))
			{
				$this->errstr='CURL unavailable on this install';
				$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_curl'], $GLOBALS['xmlrpcstr']['no_curl']);
				return $r;
			}
			if($method == 'https')
			{
				if(($info = curl_version()) &&
					((is_string($info) && strpos($info, 'OpenSSL') === null) || (is_array($info) && !isset($info['ssl_version']))))
				{
					$this->errstr='SSL unavailable on this install';
					$r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_ssl'], $GLOBALS['xmlrpcstr']['no_ssl']);
					return $r;
				}
			}

			if($port == 0)
			{
				if($method == 'http')
				{
					$port = 80;
				}
				else
				{
					$port = 443;
				}
			}

			// Only create the payload if it was not created previously
			if(empty($msg->payload))
			{
				$msg->createPayload($this->request_charset_encoding);
			}

			// Deflate request body and set appropriate request headers
			$payload = $msg->payload;
			if(function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate'))
			{
				if($this->request_compression == 'gzip')
				{
					$a = @gzencode($payload);
					if($a)
					{
						$payload = $a;
						$encoding_hdr = 'Content-Encoding: gzip';
					}
				}
				else
				{
					$a = @gzcompress($payload);
					if($a)
					{
						$payload = $a;
						$encoding_hdr = 'Content-Encoding: deflate';
					}
				}
			}
			else
			{
				$encoding_hdr = '';
			}

			if($this->debug > 1)
			{
				print "<PRE>\n---SENDING---\n" . htmlentities($payload) . "\n---END---\n</PRE>";
				// let the client see this now in case http times out...
				flush();
			}

			if(!$keepalive || !$this->xmlrpc_curl_handle)
			{
				$curl = curl_init($method . '://' . $server . ':' . $port . $this->path);
				if($keepalive)
				{
					$this->xmlrpc_curl_handle = $curl;
				}
			}
			else
			{
				$curl = $this->xmlrpc_curl_handle;
			}

			// results into variable
			curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

			if($this->debug)
			{
				curl_setopt($curl, CURLOPT_VERBOSE, 1);
			}
			curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
			// required for XMLRPC: post the data
			curl_setopt($curl, CURLOPT_POST, 1);
			// the data
			curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);

			// return the header too
			curl_setopt($curl, CURLOPT_HEADER, 1);

			// NB: if we set an empty string, CURL will add http header indicating
			// ALL methods it is supporting. This is possibly a better option than
			// letting the user tell what curl can / cannot do...
			if(is_array($this->accepted_compression) && count($this->accepted_compression))
			{
				//curl_setopt($curl, CURLOPT_ENCODING, implode(',', $this->accepted_compression));
				// empty string means 'any supported by CURL' (shall we catch errors in case CURLOPT_SSLKEY undefined ?)
				if (count($this->accepted_compression) == 1)
				{
					curl_setopt($curl, CURLOPT_ENCODING, $this->accepted_compression[0]);
				}
				else
					curl_setopt($curl, CURLOPT_ENCODING, '');
			}
			// extra headers
			$headers = array('Content-Type: ' . $msg->content_type , 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings));
			if(is_array($this->accepted_content_type) && count($this->accepted_content_type))
			{
				$headers[] = 'Accept: ' . implode(', ', $this->accepted_content_type);
			}
			// if no keepalive is wanted, let the server know it in advance
			if(!$keepalive)
			{
				$headers[] = 'Connection: close';
			}
			// request compression header
			if($encoding_hdr)
			{
				$headers[] = $encoding_hdr;
			}

			curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
			// timeout is borked
			if($timeout)
			{
				curl_setopt($curl, CURLOPT_TIMEOUT, $timeout == 1 ? 1 : $timeout - 1);
			}

			if($username && $password)
			{
				curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password);
				if (defined('CURLOPT_HTTPAUTH'))
				{
					curl_setopt($curl, CURLOPT_HTTPAUTH, $authtype);
				}
				else if ($authtype != 1)
				{
					error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth is supported by the current PHP/curl install');
				}
			}

			if($method == 'https')
			{
				// set cert file
				if($cert)
				{
					curl_setopt($curl, CURLOPT_SSLCERT, $cert);
				}
				// set cert password
				if($certpass)
				{
					curl_setopt($curl, CURLOPT_SSLCERTPASSWD, $certpass);
				}
				// whether to verify remote host's cert
				curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verifypeer);
				// set ca certificates file/dir
				if($cacert)
				{
					curl_setopt($curl, CURLOPT_CAINFO, $cacert);
				}
				if($cacertdir)
				{
					curl_setopt($curl, CURLOPT_CAPATH, $cacertdir);
				}
				// set key file (shall we catch errors in case CURLOPT_SSLKEY undefined ?)
				if($key)
				{
					curl_setopt($curl, CURLOPT_SSLKEY, $key);
				}
				// set key password (shall we catch errors in case CURLOPT_SSLKEY undefined ?)
				if($keypass)
				{
					curl_setopt($curl, CURLOPT_SSLKEYPASSWD, $keypass);
				}
				// whether to verify cert's common name (CN); 0 for no, 1 to verify that it exists, and 2 to verify that it matches the hostname used
				curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, $this->verifyhost);
			}

			// proxy info
			if($proxyhost)
			{
				if($proxyport == 0)
				{
					$proxyport = 8080; // NB: even for HTTPS, local connection is on port 8080
				}
				curl_setopt($curl, CURLOPT_PROXY, $proxyhost.':'.$proxyport);
				//curl_setopt($curl, CURLOPT_PROXYPORT,$proxyport);
				if($proxyusername)
				{
					curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyusername.':'.$proxypassword);
					if (defined('CURLOPT_PROXYAUTH'))
					{
						curl_setopt($curl, CURLOPT_PROXYAUTH, $proxyauthtype);
					}
					else if ($proxyauthtype != 1)
					{
						error_log('XML-RPC: '.__METHOD__.': warning. Only Basic auth to proxy is supported by the current PHP/curl install');
					}
				}
			}

			// NB: should we build cookie http headers by hand rather than let CURL do it?
			// the following code does not honour 'expires', 'path' and 'domain' cookie attributes
			// set to client obj the the user...
			if (count($this->cookies))
			{
				$cookieheader = '';
				foreach ($this->cookies as $name => $cookie)
				{
					$cookieheader .= $name . '=' . $cookie['value'] . '; ';
				}
				curl_setopt($curl, CURLOPT_COOKIE, substr($cookieheader, 0, -2));
			}

			foreach ($this->extracurlopts as $opt => $val)
			{
				curl_setopt($curl, $opt, $val);
			}

			$result = curl_exec($curl);

			if ($this->debug > 1)
			{
				print "<PRE>\n---CURL INFO---\n";
				foreach(curl_getinfo($curl) as $name => $val)
				{
					if (is_array($val))
					{
						$val = implode("\n", $val);
					}
					print $name . ': ' . htmlentities($val) . "\n";
				}

				print "---END---\n</PRE>";
			}

			if(!$result) /// @todo we should use a better check here - what if we get back '' or '0'?
			{
				$this->errstr='no response';
				$resp=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['curl_fail'], $GLOBALS['xmlrpcstr']['curl_fail']. ': '. curl_error($curl));
				curl_close($curl);
				if($keepalive)
				{
					$this->xmlrpc_curl_handle = null;
				}
			}
			else
			{
				if(!$keepalive)
				{
					curl_close($curl);
				}
				$resp =& $msg->parseResponse($result, true, $this->return_type);
                // if we got back a 302, we can not reuse the curl handle for later calls
                if($resp->faultCode() == $GLOBALS['xmlrpcerr']['http_error'] && $keepalive)
                {
                    curl_close($curl);
                    $this->xmlrpc_curl_handle = null;
                }
			}
			return $resp;
		}
662961
def call( methodName, args )
      args = (args || {}) #.keys_to_sym!

      # Get Binding
      binding = @wsdl.bindings.getBindingForOperationName( @binding, methodName )
      if binding.size == 0
        raise SOAP::LCNoMethodError, "Undefined method `#{methodName}'"
      elsif binding.size > 1
        raise SOAP::LCError, "Ambigous method name `#{methodName}', please, specify a binding name"
      else
        binding = binding[0]
        @binding = binding.name
      end

      # Get Binding Operation
      binding_operation = binding.operations[methodName]

      # Get PortType
      portType = @wsdl.portTypes[binding.type.nns]
      portType_operation = portType.operations[methodName]

      # Get message for input operation
      input_message = @wsdl.messages[portType_operation[:input][:message].nns]

      # Create method
      soap_method = "<#{methodName} xmlns=\"#{@wsdl.targetNamespace}\">\n"
      input_message.parts.each do |_, attrs|
        case attrs[:mode]
          when :type
            if SOAP::XSD::ANY_SIMPLE_TYPE.include?( attrs[attrs[:mode]].nns )
              # Part refer to a builtin SimpleType
              soap_method << SOAP::XSD.displayBuiltinType( attrs[:name], args, 1, 1 )
            else
              # Part refer to an XSD simpleType or complexType defined in types
              element = @wsdl.types[attrs[attrs[:mode]].nns][:value]
              case element[:type]
                when :simpleType
                  soap_method << "<#{attrs[:name]}>\n#{element.display( @wsdl.types, args )}\n</#{attrs[:name]}>\n" # MAYBE ########## 
                when :complexType
                  soap_method << "<#{attrs[:name]}>\n#{element.display( @wsdl.types, args )}\n</#{attrs[:name]}>\n" # MAYBE ########## 
                else
                  raise SOAP::LCWSDLError, "Malformated part #{attrs[:name]}"
              end
            end
          when :element
            # Part refer to an XSD element
            element = @wsdl.types[attrs[attrs[:mode]].nns][:value]
            case element[:type]
              when :simpleType
                soap_method << element[element[:type]].display( @wsdl.types, args )
              when :complexType
                soap_method << element[element[:type]].display( @wsdl.types, args )
              else
                raise SOAL::LCWSDLError, "Malformated element `#{attrs[attrs[:mode]]}'"
            end
        
            ## TODO ---------- USE element[:key]
          else 
            raise SOAP::LCWSDLError, "Malformated part #{attrs[:name]}"
        end
      end
      soap_method += "</#{methodName}>\n"

      # Create SOAP Envelope
      envelope = soap_envelop do 
        soap_header + soap_body( soap_method )
      end

      # Create headers
      headers = Hash.new
      # Add SOAPAction to headers (if exist)
      action = begin
        binding_operation[:soapAction]
      rescue
        nil
      end
      headers['SOAPAction'] = action unless action.nil? or action.length == 0

      # Search URI
      service_port = @wsdl.services.getServicePortForBindingName( binding.name )
      address = service_port[:address]

      # Complete request
      @request = {
        :headers  => make_header( envelope, headers ),
        :envelope => envelope,
        :uri      => address,
        :wsdl     => @wsdl,
        :response => @wsdl.messages[portType_operation[:output][:message].nns].name,
        :binding  => @binding,
        :method   => methodName
      }
      
      return self
    end
251142
def dump_soap_response(service_url, response_xml)
      return unless @soap_dump
      response_xml.gsub(/<email[^>]*>.+<\/email>/, "<email>**censured**</email>")
      str = ""
      str << "<!-- response -->\n" unless @soap_dump_dir
      str << xml_to_s(response_xml) << "\n"
      str << "<!-- end -->" unless @soap_dump_dir
      dump(service_url, "res", str)
    end
486250
def get_soap_object(self, client):
        
        def to_soap_attribute(attr):
            words = attr.split('_')
            words = words[:1] + [word.capitalize() for word in words[1:]]
            return ''.join(words)

        soap_object = client.factory.create(self.soap_name)
        for attr in self._attributes:
            value = getattr(self, attr)
            setattr(soap_object, to_soap_attribute(attr), value)

        return soap_object
998060
def processRequest(cls, ps, **kw):
        
        resource = kw['resource']
        request = kw['request']
        method =  getattr(resource, 'soap_%s' %
                           _get_element_nsuri_name(ps.body_root)[-1])
                                              
        try:
            req_pyobj,rsp_pyobj = method(ps, request=request)
        except TypeError, ex:
            log.err(
                'ERROR: service %s is broken, method MUST return request, response'\
                    % cls.__name__
            )
            raise
        except Exception, ex:
            log.err('failure when calling bound method')
            raise
        
        return rsp_pyobj
455916
def open(self, request):
        
        url = request.url
        logger.debug('Opening WSDL: %s ' % url)
        statsd.incr('soap.open')
        with statsd.timer('soap.open'):
            if url.startswith('file://'):
                content = urllib.request.urlopen(url)
            else:
                resp = requests.get(url,
                    proxies=self.proxies(url),
                    timeout=self.open_timeout)
                resp.raise_for_status()
                content = io.BytesIO(resp.content)
        return content
667542
def _create_request(headers, body):
        
        envelope = OrderedDict()
        for (namespace, alias) in Service.Namespaces.items():
            envelope['@xmlns:' + alias] = namespace
        envelope['soap:Header'] = headers
        envelope['soap:Body'] = body
        return xmltodict.unparse({'soap:Envelope': envelope}, encoding='utf-8')
602991
public SoapClientRequestActionBuilder send() {
        SoapClientRequestActionBuilder soapClientRequestActionBuilder;
        if (soapClient != null) {
            soapClientRequestActionBuilder = new SoapClientRequestActionBuilder(action, soapClient);
        } else {
            soapClientRequestActionBuilder = new SoapClientRequestActionBuilder(action, soapClientUri);
        }

        soapClientRequestActionBuilder.withApplicationContext(applicationContext);

        return soapClientRequestActionBuilder;
    }
882770
public function SoapVar($data, $encoding, $type_name = NULL, $type_namespace = NULL, $node_name = NULL, $node_namespace = NULL)
    {
    }
1253917
def dump_soap_request(service_url, request_xml)
      return unless @soap_dump
      %w{email password developerToken authToken clientEmail}.each do |tag|
        request_xml = request_xml.gsub(/<#{tag}([^>]*)>.*<\/#{tag}>/, "<#{tag}\\1>***censured***</#{tag}>")
      end
      str = ""
      str << "<!-- Post to '#{service_url}' -->\n"
      str << xml_to_s(request_xml) << "\n"
      dump(service_url, "req", str)
    end
201549
def WSDLUriToVersion(self, uri):
        """"""
        value = self._wsdl_uri_mapping.get(uri)
        if value is not None:
            return value
        raise ValueError(
            'Unsupported SOAP envelope uri: %s' % uri
            )
815361
public static SoapClient create(String url, SoapProtocol protocol, String namespaceURI) {
		return new SoapClient(url, protocol, namespaceURI);
	}
503604
protected SoapCall<T> createSoapCall(Method soapClientMethod, Object[] args) {
    return new SoapCall<T>(soapClientMethod, soapClient, args);
  }
115425
function requestGoogleNewsRSS(params, callback) {
    // parse the params
    var returnObject = parseGoogleNewsRSSParams(params);
    returnObject.newsArray = null;
    // if no error from the parsing object
    if (!returnObject.error) {
        // make a request to the RSS using the URL
        var request = require("request");
        request({uri: returnObject.url}, 
        function(error, response, body) {
            // if no error in the call
            if (!error) {
                // parse the RSS data
                var parsedData = parseGoogleNewsRSSData(body);
                // if parsing runs okay, add data to the return object and return it
                if (parsedData.error == false) {
                    returnObject.error = false;      
                    returnObject.errorMessage = null;
                    returnObject.newsArray = parsedData.data;
                    callback(returnObject);
                }                    
                // otherwise parsing failed, indicate such
                else {
                    returnObject.error = true;
                    returnObject.errorMessage = 'Error with parsing data return from Google News.';
                    callback(returnObject);
                }
            }
            // otherwise indicate bad request
            else {
                returnObject.error = true;
                returnObject.errorMessage = 'Error with request for data from Google News.';
                callback(returnObject);
            }
        });        
    }
    // otherwise send back error true object from original params parsing
    else {
        callback(returnObject);
    }
}