p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   .NET Web Services (http://p2p.wrox.com/forumdisplay.php?f=102)
-   -   About method of class in Web Service (http://p2p.wrox.com/showthread.php?t=7040)

hueduongit December 9th, 2003 05:00 AM

About method of class in Web Service
 
Hi all

My web service has class clsDemo. The class has method methodTry (public string methodTry).
Create class proxy for this web service. Receive class has not methodTry() method, only has properties public and variables public
WHY???
Help me! Thanks for your help!


planoie December 9th, 2003 10:20 AM

Have you defined this method as a "WebMethod"? I believe in C# the syntax is...

[WebMethod]
public string methodTry()...

Peter
------------------------------------------------------
Work smarter, not harder.

hueduongit December 10th, 2003 04:23 AM

Thank you very much
    The method mentioned aboved does not belong to the ws but to a class in that ws. It is here

    File DataType.asmx.cs
    //...
    public class DataType : System.Web.Services.WebService
    {
        //
        public class clsName
        {
            public string m_ID = "";
            public string m_Comment = "";
            private string m_Hide = "";

            public string methodTry() // It has not in proxy class
            {
                return (m_Hide);
            }
        }

        //...
        public clsName GetClass(string strId, strComment)
        {
            clsName cl = new clsName();
            cl.m_ID = strId;
            cl.m_Comment = strComment;
            cl.m_Hide = "hide";
            return (cl);
        }
        //...
    }
    //...

    File proxy class DataType.cs
    //...
        public class DataType : System.Web.Services.Protocols.SoapHttpClientProtoc ol
    {
                /// <remarks/>
                public DataType()
        {
                        this.Url = "http://localhost/Ws/DataType.asmx";
                }
        //...
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://tempuri.org/")]
    public class clsName
    {
                /// <remarks/>
                public string m_ID;

                /// <remarks/>
                public string m_Comment;

        //??? Hope something at here
    }


hueduongit December 10th, 2003 04:26 AM

ah, as far as i still don't solve problem Execute method of web service, about database
( http://p2p.wrox.com/topic.asp?TOPIC_ID=6909 )


planoie December 10th, 2003 12:03 PM

The WSDL for a web service is only going to define the data structures and web methods available. The idea of a web service is to have the web service do the work and just return data. It makes little sense to have a web service return you code. That kind of defeats the purpose of the service.

Perhaps what you are intending here is to create a property accessor. Public properties of classes will show up in the web service data structures. Set up your class like this:

public class clsName
{
    public string m_ID = "";
    public string m_Comment = "";
    private string m_Hide = "";

    public string methodTry() // It has not in proxy class
    {
        get
        {
            return (m_Hide);
        }
    }
}

And you should end up with something like this in your proxy class:

public class clsName
{
    /// <remarks/>
    public string m_ID;

    /// <remarks/>
    public string m_Comment;

    /// <remarks/>
    public string methodTry;
}

I'm not sure what will actually happen with a readonly property in the proxy class so I might be wrong on this.

Peter
------------------------------------------------------
Work smarter, not harder.

hueduongit December 11th, 2003 09:09 PM

Thank you, Peter!
Because, I read documment to see WS supports a significant number of data types and there is class type. I think it also supports for methods of class. Then it limit, class only use to contain data.



All times are GMT -4. The time now is 03:59 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.