Reputation: 408
I have one ASMX webservice with C#. In this WebService I use some classes with properties. The Class is in the same namespace as Service1.asmx.
Code of my Web Service:
namespace NewWebService
{
[WebService(Namespace = "http://www.MySite.net/")]
[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 GetUsers(string authenticatedToken) //out string error
{
//Extract from database the users...
return Serialize(usersList);
}
...
}
}
Code of my class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace NewWebService
{
public class Users
{
public int ID { get; set; }
public string Name { get; set; }
...
}
}
The question is: what must I make with my class to can view it in project where I added the webservice.
Upvotes: 1
Views: 1937
Reputation: 219047
You're returning a string
:
public string GetUsers(string authenticatedToken)
So the public definition for the web service is only going to expose information about a string
. There's nothing in the public interface regarding your class, so the web service doesn't advertise any information about your class.
Return a strongly-typed instance of the class. Something like this:
public IEnumerable<User> GetUsers(string authenticatedToken)
Then the generated web service code will include a definition of the type being returned, so consuming clients will be able to understand that type. (And, for example, generate a local analog of that type if the consuming client includes code-generating capabilities. It wouldn't be the same type from an assembly perspective, but across a service boundary that shouldn't really be a concern.)
Upvotes: 3