Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0
hi,
 
My webservice code is,
 
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
 
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
    public Service () {
 
        //Uncomment the following line if using designed components
        //InitializeComponent();
    }
 
    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }
    [WebMethod]
    public int Addtion(int x, int y)
    {
        return x + y;
    }
}
and my application code is:
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 

namespace SimpleApplication
 
{
    public partial class Form1 : Form
    {
        localhost.Service loc = new SimpleApplication.localhost.Service();
        public Form1()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            int a, b, c;
            a = Convert .ToInt16 ( textBox1.Text);
            b = Convert.ToInt16 ( textBox2.Text);
            c = loc.Addtion(a, b);
            textBox3.Text = c.ToString();
            MessageBox.Show("" + c);
        }
    }
}
 

 
in REFERENCE.CS page i will get error like this "Could not establish connection to network"
 
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Addtion", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        public int Addtion(int x, int y) {
            object[] results = this.Invoke("Addtion", new object[] {
                        x,
                        y});
            return ((int)(results[0]));
        }
Posted 11-Jul-13 23:02pm
Comments
Sushil Mate at 12-Jul-13 4:58am
   
You need to learn basics of web services first. is your webservice is running on localhost?
ryanb31 at 12-Jul-13 12:15pm
   
Isn't the error clear?

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

  Print Answers RSS
0 BillWoodruff 300
1 Mathew Soji 274
2 Afzaal Ahmad Zeeshan 268
3 DamithSL 225
4 Sergey Alexandrovich Kryukov 205
0 OriginalGriff 6,249
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 3,865


Advertise | Privacy | Mobile
Web02 | 2.8.1411019.1 | Last Updated 12 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100