C# Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

C# Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML to XML
HTTP
IMAP
Encryption
MHT / HTML Email
MIME
RSA Encryption
S/MIME
Socket
Spider
Tar Archive
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
POP3
SMTP
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA

Unreleased...
Bzip2
LZW
Bz2
Icon

 

 

 

 

 

 

Using XMLHTTP with GOOGLE's SOAP API

Download Chilkat .NET for 2.0 / 3.5 Framework

Download Chilkat .NET for 1.0 / 1.1 Framework

C# example showing how to do a Google search using Google's SOAP API.

Chilkat.Http http = new Chilkat.Http();
bool unlocked = http.UnlockComponent("Any string begins 30-day trial");
if (!unlocked)
{
    MessageBox.Show("Failed to unlock HTTP component");
    return;
}

// Results in China may not be the same as elsewhere...
string search = "China Internet censorship";

string soapRequest = "<?xml version='1.0' encoding='UTF-8'?>"+"\n\n"+"<SOAP-ENV:Envelope"+
    " xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\""+
    " xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\""+
    " xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\">"+
    "<SOAP-ENV:Body><ns1:doGoogleSearch"+
    " xmlns:ns1=\"urn:GoogleSearch\""+
    " SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"+
    "<key xsi:type=\"xsd:string\">YOUR_GOOGLE_API_KEY_HERE</key> <q"+
    " xsi:type=\"xsd:string\">"+search+"</q> <start"+
    " xsi:type=\"xsd:int\">0</start> <maxResults"+
    " xsi:type=\"xsd:int\">10</maxResults> <filter"+
    " xsi:type=\"xsd:boolean\">true</filter> <restrict"+
    " xsi:type=\"xsd:string\"></restrict> <safeSearch"+
    " xsi:type=\"xsd:boolean\">false</safeSearch> <lr"+
    " xsi:type=\"xsd:string\"></lr> <ie"+
    " xsi:type=\"xsd:string\">latin1</ie> <oe"+
    " xsi:type=\"xsd:string\">latin1</oe>"+
    "</ns1:doGoogleSearch>"+
    "</SOAP-ENV:Body></SOAP-ENV:Envelope>";

Chilkat.HttpRequest req = new Chilkat.HttpRequest();
req.UseXmlHttp(soapRequest);
req.Path = "/search/beta2";
req.AddHeader("MessageType","CALL");

bool ssl = false;   // Set this to true to use HTTPS
Chilkat.HttpResponse resp = http.SynchronousRequest("api.google.com",80,false,req);
if (resp == null) 
{
    MessageBox.Show(http.LastErrorText);
    return;
}

// Did we get a successful response?
if (resp.StatusCode == 200)
{
    // Success!
    // Display the XML document we received.
    textBox1.Text = resp.BodyStr;	
    
    // Load the XML into a Chilkat.Xml object.
    Chilkat.Xml xml = new Chilkat.Xml();
    xml.LoadXml(resp.BodyStr);
    
    string strUrls = "";
    
    // Pick out all the URLs and display them.
    Chilkat.Xml xUrl = xml.SearchForTag(null,"URL");	 
    while (xUrl != null)
    {
	strUrls += xUrl.Content + "\r\n";
	xUrl = xml.SearchForTag(xUrl,"URL");
    }   
    MessageBox.Show(strUrls);
}
else
{
    // Failed!
    // Show the full response header...
    MessageBox.Show(resp.Header);
}		    

Important: The download for this example does not contain the ChilkatDotNet2.dll which
must be downloaded and installed separately at http://www.chilkatsoft.com/downloads.asp.
Once installed, add a reference to the DLL in the project by following the instructions at
http://www.example-code.com/csharp/step2.asp

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.

Email Component · XML Parser