Monday, October 13, 2014

Webservicessss1


  • adding service references..

RC on reference
add SERVICE reference
type url of web service
go
type name
then ok
============================
currency convertor- client.. webservice is else where-------------------------------------------
//---Form1.cs
//----ServiceReference1 is d name given for reference here
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Webservice1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            loading();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            String one = comboBox1.SelectedItem.ToString();
            String two = comboBox2.SelectedItem.ToString();
            int three = Int32.Parse(textBox3.Text);

            ServiceReference1.Currency cd = (ServiceReference1.Currency)Enum.Parse(typeof(ServiceReference1.Currency), one);
            ServiceReference1.Currency cd1 = (ServiceReference1.Currency)Enum.Parse(typeof(ServiceReference1.Currency), two);


            ServiceReference1.CurrencyConvertorSoapClient ws = new ServiceReference1.CurrencyConvertorSoapClient("CurrencyConvertorSoap");
            double ds = ws.ConversionRate(cd, cd1);
            double result = ds * three;

            label5.Text = result.ToString();


        }

        public void loading()
        {
            foreach (var item in Enum.GetValues(typeof(ServiceReference1.Currency)))
            {
                comboBox1.Items.Add(item);
                comboBox2.Items.Add(item);
            }
        }
    }
}

//--------------------------------------------------------------------
//program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace Webservice1
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}

No comments:

Post a Comment