views:

63

answers:

1

I am developing a RIA application in silverlight and my requirement is that I want to create a class in a webservice and that class will have some public properties. Theses properties I have to access in the silverlight application. I have created the webservice that’s not a problem . The issue is using that class's properties in the silverlight I can use its web methods but not the properties please help

+1  A: 

Without seeing some sample of the code, it is hard to tell, but if I understand you properly...

You will want to create a class in the same project as your Web Service that has the properties you want to access, and then make that class the return type of the Web Service. The class will have to be marked with the [Serializable] tag so that the web service and Silverlight can do the XML Serialization automagically.

For example in your Web service project, create MyClass.cs:

[Serializable]
public class MyClass
{
    public string SomeProperty { get; set; }
    public int SomeOtherProperty { get; set; }
}

And then in your web service.asmx code-behind:

[WebMethod]
public MyClass SomeWebServiceMethod(string someArg)
{
    MyClass returnValue = new MyClass();
    returnValue.SomeProperty = someArg;
    returnValue.SomeOtherProperty = 42;

    return returnValue;
}
Tony Heupel