Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / March 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
WG - 28 Mar 2007 01:10 GMT
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
Manish Bafna - 28 Mar 2007 03:00 GMT
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.
Signature

If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

> Hi,
>
[quoted text clipped - 30 lines]
>
> Thanks
Manish Bafna - 28 Mar 2007 05:18 GMT
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
Signature

If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

> Hi,
>
[quoted text clipped - 30 lines]
>
> Thanks
WG - 28 Mar 2007 22:08 GMT
Thanks for your reply Manish.  I tried this and now get a stack overflow when
the ws is called.

> Hi,
> Actually [XmlInclude(typeof(Class1))] will come before class:
[quoted text clipped - 50 lines]
> >
> > Thanks
Manish Bafna - 29 Mar 2007 07:48 GMT
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
Signature

If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

> Thanks for your reply Manish.  I tried this and now get a stack overflow when
> the ws is called.
[quoted text clipped - 53 lines]
> > >
> > > Thanks
WG - 30 Mar 2007 17:34 GMT
Thanks Manish.

> Hi,
> Actually you need to serialize the class in proper way and then also need to
[quoted text clipped - 60 lines]
> > > >
> > > > Thanks

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.