all groups > dotnet web services > march 2007 >
You're in the

dotnet web services

group:

Can't see public method on object returned from web service


Can't see public method on object returned from web service WG
3/27/2007 5:10:17 PM
dotnet web services:
Hi,

I have the following ws method...

[WebMethod]
public Class1 GetClass1()
{
return new Class1();
}


Class1 looks like....

public class Class1
{
protected string _prop;
public string Prop
{
get { return _prop; }
set { _prop = value; }
}

public void Test(string s)
{
// do some stuff
}
}

When I look at the returned instance of Class1 I can see the public property
but not the method.

Can anyone tell me what I am doing wrong. The client is a aspx page using
a regular .net 2.0 web reference.

Thanks
RE: Can't see public method on object returned from web service Manish Bafna
3/27/2007 7:00:59 PM
Hi,
try this code:

[WebMethod]
[XmlInclude(typeof(Class1))]
public Class1 GetClass1()
{
return new Class1();
}
You will need to add using System.Xml.Serialization; to your using section .
Hope this helps.
--
If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.



[quoted text, click to view]
RE: Can't see public method on object returned from web service Manish Bafna
3/27/2007 9:18:00 PM
Hi,
Actually [XmlInclude(typeof(Class1))] will come before class:

[XmlInclude(typeof(Class1))]
public class Class1
{
protected string _prop;
public string Prop
{
get { return _prop; }
set { _prop = value; }
}

public void Test(string s)
{
// do some stuff
}
}
Hope this helps
--
If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.



[quoted text, click to view]
RE: Can't see public method on object returned from web service WG
3/28/2007 2:08:05 PM
Thanks for your reply Manish. I tried this and now get a stack overflow when
the ws is called.


[quoted text, click to view]
RE: Can't see public method on object returned from web service Manish Bafna
3/28/2007 11:48:01 PM
Hi,
Actually you need to serialize the class in proper way and then also need to
deserialize the class at the client side where web service is consumed.Please
do google on how to serialize/deserialize the class and you will find further
samples/code snippets.
Hope this hepls
--
If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.



[quoted text, click to view]
RE: Can't see public method on object returned from web service WG
3/30/2007 9:34:01 AM
Thanks Manish.

[quoted text, click to view]
AddThis Social Bookmark Button