troubleshooting Question

a very simple web service in C# is not working, Why?

Avatar of jazzIIIlove
jazzIIIloveFlag for Sweden asked on
C#WCF
9 Comments1 Solution322 ViewsLast Modified:
Hi there;

I implemented a very simple web service that requires a number as a parameter.

The web service code is as follows:

There are 2 files; one is as; Service1.asmx.cs and the other is ClientData.cs.

When I run the solution, the service seems to work but the passed parameter is not reflecting the outcome as attached.

What should I do?

Kind regards.
//Service1.asmx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace WebService1
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class Service1 : System.Web.Services.WebService
    {

        [WebMethod]
        //public string HelloWorld()
        public ClientData[] Invoke()
        {
            ClientData clientData = new ClientData();

            return clientData.GetClientData(5);
        }
    }
}

//ClientData.cs
using System.Web.Services;
namespace WebService1
{
    public class ClientData
    {
        public string Name;
        public int Id;

        [WebMethod]
        public ClientData[] GetClientData(int Number)
        {
            ClientData[] Clients = null;

            if (Number > 0 && Number <= 10)
            {
                Clients = new ClientData[Number];

                for (int i = 0; i < Number; i++)
                {
                    Clients[i].Name = "Client " + i.ToString();
                    Clients[i].Id = i;
                }
            }
            return Clients;
        }
    }
}
notworkingplaceholders.jpg
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 9 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros