Click here to Skip to main content
15,896,606 members
Articles / Web Development

Consuming a Json WebService from a C# or VB Application

Rate me:
Please Sign up or sign in to vote.
4.81/5 (26 votes)
2 Apr 2012CPOL7 min read 334K   23.7K   94  
Some steps for consuming a Json web service from a C# application
namespace Panoramio
{
    partial class Form1
    {
        /// <summary>
        /// Erforderliche Designervariable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Verwendete Ressourcen bereinigen.
        /// </summary>
        /// <param name="disposing">True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Vom Windows Form-Designer generierter Code

        /// <summary>
        /// Erforderliche Methode für die Designerunterstützung.
        /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
        /// </summary>
        private void InitializeComponent()
        {
            this.label1 = new System.Windows.Forms.Label();
            this.rbtPublic = new System.Windows.Forms.RadioButton();
            this.rbtAll = new System.Windows.Forms.RadioButton();
            this.rbtUserID = new System.Windows.Forms.RadioButton();
            this.txtUserID = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.cmbSize = new System.Windows.Forms.ComboBox();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.txtMinX = new System.Windows.Forms.TextBox();
            this.txtMaxX = new System.Windows.Forms.TextBox();
            this.label5 = new System.Windows.Forms.Label();
            this.txtMaxY = new System.Windows.Forms.TextBox();
            this.label6 = new System.Windows.Forms.Label();
            this.txtMinY = new System.Windows.Forms.TextBox();
            this.label7 = new System.Windows.Forms.Label();
            this.label8 = new System.Windows.Forms.Label();
            this.txtResultMax = new System.Windows.Forms.TextBox();
            this.label9 = new System.Windows.Forms.Label();
            this.txtResultMin = new System.Windows.Forms.TextBox();
            this.label10 = new System.Windows.Forms.Label();
            this.label11 = new System.Windows.Forms.Label();
            this.chkMapFilter = new System.Windows.Forms.CheckBox();
            this.btnStart = new System.Windows.Forms.Button();
            this.btnJavaScriptSerializer = new System.Windows.Forms.Button();
            this.txtGeonamesUser = new System.Windows.Forms.TextBox();
            this.label12 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(12, 15);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(26, 13);
            this.label1.TabIndex = 0;
            this.label1.Text = "Set:";
            // 
            // rbtPublic
            // 
            this.rbtPublic.AutoSize = true;
            this.rbtPublic.Location = new System.Drawing.Point(85, 13);
            this.rbtPublic.Name = "rbtPublic";
            this.rbtPublic.Size = new System.Drawing.Size(61, 17);
            this.rbtPublic.TabIndex = 1;
            this.rbtPublic.TabStop = true;
            this.rbtPublic.Text = "Popular";
            this.rbtPublic.UseVisualStyleBackColor = true;
            // 
            // rbtAll
            // 
            this.rbtAll.AutoSize = true;
            this.rbtAll.Location = new System.Drawing.Point(145, 13);
            this.rbtAll.Name = "rbtAll";
            this.rbtAll.Size = new System.Drawing.Size(36, 17);
            this.rbtAll.TabIndex = 2;
            this.rbtAll.TabStop = true;
            this.rbtAll.Text = "All";
            this.rbtAll.UseVisualStyleBackColor = true;
            // 
            // rbtUserID
            // 
            this.rbtUserID.AutoSize = true;
            this.rbtUserID.Location = new System.Drawing.Point(198, 13);
            this.rbtUserID.Name = "rbtUserID";
            this.rbtUserID.Size = new System.Drawing.Size(64, 17);
            this.rbtUserID.TabIndex = 3;
            this.rbtUserID.TabStop = true;
            this.rbtUserID.Text = "User-ID:";
            this.rbtUserID.UseVisualStyleBackColor = true;
            // 
            // txtUserID
            // 
            this.txtUserID.Location = new System.Drawing.Point(268, 12);
            this.txtUserID.Name = "txtUserID";
            this.txtUserID.Size = new System.Drawing.Size(122, 20);
            this.txtUserID.TabIndex = 4;
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(12, 43);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(30, 13);
            this.label2.TabIndex = 5;
            this.label2.Text = "Size:";
            // 
            // cmbSize
            // 
            this.cmbSize.FormattingEnabled = true;
            this.cmbSize.Location = new System.Drawing.Point(85, 40);
            this.cmbSize.Name = "cmbSize";
            this.cmbSize.Size = new System.Drawing.Size(305, 21);
            this.cmbSize.TabIndex = 6;
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(12, 76);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(57, 13);
            this.label3.TabIndex = 7;
            this.label3.Text = "Longitude:";
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(82, 76);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(27, 13);
            this.label4.TabIndex = 8;
            this.label4.Text = "from";
            // 
            // txtMinX
            // 
            this.txtMinX.Location = new System.Drawing.Point(115, 73);
            this.txtMinX.Name = "txtMinX";
            this.txtMinX.Size = new System.Drawing.Size(111, 20);
            this.txtMinX.TabIndex = 9;
            this.txtMinX.Text = "-180";
            this.txtMinX.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            // 
            // txtMaxX
            // 
            this.txtMaxX.Location = new System.Drawing.Point(278, 73);
            this.txtMaxX.Name = "txtMaxX";
            this.txtMaxX.Size = new System.Drawing.Size(112, 20);
            this.txtMaxX.TabIndex = 11;
            this.txtMaxX.Text = "180";
            this.txtMaxX.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(245, 76);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(16, 13);
            this.label5.TabIndex = 10;
            this.label5.Text = "to";
            // 
            // txtMaxY
            // 
            this.txtMaxY.Location = new System.Drawing.Point(278, 99);
            this.txtMaxY.Name = "txtMaxY";
            this.txtMaxY.Size = new System.Drawing.Size(112, 20);
            this.txtMaxY.TabIndex = 16;
            this.txtMaxY.Text = "90";
            this.txtMaxY.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            // 
            // label6
            // 
            this.label6.AutoSize = true;
            this.label6.Location = new System.Drawing.Point(245, 102);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(16, 13);
            this.label6.TabIndex = 15;
            this.label6.Text = "to";
            // 
            // txtMinY
            // 
            this.txtMinY.Location = new System.Drawing.Point(115, 99);
            this.txtMinY.Name = "txtMinY";
            this.txtMinY.Size = new System.Drawing.Size(111, 20);
            this.txtMinY.TabIndex = 14;
            this.txtMinY.Text = "-90";
            this.txtMinY.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            // 
            // label7
            // 
            this.label7.AutoSize = true;
            this.label7.Location = new System.Drawing.Point(82, 102);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(27, 13);
            this.label7.TabIndex = 13;
            this.label7.Text = "from";
            // 
            // label8
            // 
            this.label8.AutoSize = true;
            this.label8.Location = new System.Drawing.Point(12, 102);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(48, 13);
            this.label8.TabIndex = 12;
            this.label8.Text = "Latitude:";
            // 
            // txtResultMax
            // 
            this.txtResultMax.Location = new System.Drawing.Point(278, 135);
            this.txtResultMax.Name = "txtResultMax";
            this.txtResultMax.Size = new System.Drawing.Size(112, 20);
            this.txtResultMax.TabIndex = 21;
            this.txtResultMax.Text = "20";
            this.txtResultMax.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            // 
            // label9
            // 
            this.label9.AutoSize = true;
            this.label9.Location = new System.Drawing.Point(245, 138);
            this.label9.Name = "label9";
            this.label9.Size = new System.Drawing.Size(16, 13);
            this.label9.TabIndex = 20;
            this.label9.Text = "to";
            // 
            // txtResultMin
            // 
            this.txtResultMin.Location = new System.Drawing.Point(115, 135);
            this.txtResultMin.Name = "txtResultMin";
            this.txtResultMin.Size = new System.Drawing.Size(111, 20);
            this.txtResultMin.TabIndex = 19;
            this.txtResultMin.Text = "0";
            this.txtResultMin.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            // 
            // label10
            // 
            this.label10.AutoSize = true;
            this.label10.Location = new System.Drawing.Point(82, 138);
            this.label10.Name = "label10";
            this.label10.Size = new System.Drawing.Size(27, 13);
            this.label10.TabIndex = 18;
            this.label10.Text = "from";
            // 
            // label11
            // 
            this.label11.AutoSize = true;
            this.label11.Location = new System.Drawing.Point(12, 138);
            this.label11.Name = "label11";
            this.label11.Size = new System.Drawing.Size(55, 13);
            this.label11.TabIndex = 17;
            this.label11.Text = "Results #:";
            // 
            // chkMapFilter
            // 
            this.chkMapFilter.AutoSize = true;
            this.chkMapFilter.Checked = true;
            this.chkMapFilter.CheckState = System.Windows.Forms.CheckState.Checked;
            this.chkMapFilter.Location = new System.Drawing.Point(15, 175);
            this.chkMapFilter.Name = "chkMapFilter";
            this.chkMapFilter.Size = new System.Drawing.Size(69, 17);
            this.chkMapFilter.TabIndex = 22;
            this.chkMapFilter.Text = "Map filter";
            this.chkMapFilter.UseVisualStyleBackColor = true;
            // 
            // btnStart
            // 
            this.btnStart.Location = new System.Drawing.Point(50, 265);
            this.btnStart.Name = "btnStart";
            this.btnStart.Size = new System.Drawing.Size(147, 23);
            this.btnStart.TabIndex = 23;
            this.btnStart.Text = "DataContractJsonSerializer";
            this.btnStart.UseVisualStyleBackColor = true;
            this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
            // 
            // btnJavaScriptSerializer
            // 
            this.btnJavaScriptSerializer.Location = new System.Drawing.Point(214, 265);
            this.btnJavaScriptSerializer.Name = "btnJavaScriptSerializer";
            this.btnJavaScriptSerializer.Size = new System.Drawing.Size(142, 23);
            this.btnJavaScriptSerializer.TabIndex = 24;
            this.btnJavaScriptSerializer.Text = "JavaScriptSerializer";
            this.btnJavaScriptSerializer.UseVisualStyleBackColor = true;
            this.btnJavaScriptSerializer.Click += new System.EventHandler(this.btnJavaScriptSerializer_Click);
            // 
            // txtGeonamesUser
            // 
            this.txtGeonamesUser.Location = new System.Drawing.Point(145, 218);
            this.txtGeonamesUser.Name = "txtGeonamesUser";
            this.txtGeonamesUser.Size = new System.Drawing.Size(245, 20);
            this.txtGeonamesUser.TabIndex = 26;
            this.txtGeonamesUser.Text = "demo";
            // 
            // label12
            // 
            this.label12.AutoSize = true;
            this.label12.Location = new System.Drawing.Point(12, 221);
            this.label12.Name = "label12";
            this.label12.Size = new System.Drawing.Size(113, 13);
            this.label12.TabIndex = 25;
            this.label12.Text = "Geonames user name:";
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(402, 309);
            this.Controls.Add(this.txtGeonamesUser);
            this.Controls.Add(this.label12);
            this.Controls.Add(this.btnJavaScriptSerializer);
            this.Controls.Add(this.btnStart);
            this.Controls.Add(this.chkMapFilter);
            this.Controls.Add(this.txtResultMax);
            this.Controls.Add(this.label9);
            this.Controls.Add(this.txtResultMin);
            this.Controls.Add(this.label10);
            this.Controls.Add(this.label11);
            this.Controls.Add(this.txtMaxY);
            this.Controls.Add(this.label6);
            this.Controls.Add(this.txtMinY);
            this.Controls.Add(this.label7);
            this.Controls.Add(this.label8);
            this.Controls.Add(this.txtMaxX);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.txtMinX);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.cmbSize);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.txtUserID);
            this.Controls.Add(this.rbtUserID);
            this.Controls.Add(this.rbtAll);
            this.Controls.Add(this.rbtPublic);
            this.Controls.Add(this.label1);
            this.Name = "Form1";
            this.Text = "Panoramio-JSON";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.RadioButton rbtPublic;
        private System.Windows.Forms.RadioButton rbtAll;
        private System.Windows.Forms.RadioButton rbtUserID;
        private System.Windows.Forms.TextBox txtUserID;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.ComboBox cmbSize;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.TextBox txtMinX;
        private System.Windows.Forms.TextBox txtMaxX;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.TextBox txtMaxY;
        private System.Windows.Forms.Label label6;
        private System.Windows.Forms.TextBox txtMinY;
        private System.Windows.Forms.Label label7;
        private System.Windows.Forms.Label label8;
        private System.Windows.Forms.TextBox txtResultMax;
        private System.Windows.Forms.Label label9;
        private System.Windows.Forms.TextBox txtResultMin;
        private System.Windows.Forms.Label label10;
        private System.Windows.Forms.Label label11;
        private System.Windows.Forms.CheckBox chkMapFilter;
        private System.Windows.Forms.Button btnStart;
        private System.Windows.Forms.Button btnJavaScriptSerializer;
        private System.Windows.Forms.TextBox txtGeonamesUser;
        private System.Windows.Forms.Label label12;
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions