Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
|
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 9th, 2003, 05:00 AM
Authorized User
 
Join Date: Nov 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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!

 
Old December 9th, 2003, 10:20 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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

[WebMethod]
public string methodTry()...

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old December 10th, 2003, 04:23 AM
Authorized User
 
Join Date: Nov 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
    }

 
Old December 10th, 2003, 04:26 AM
Authorized User
 
Join Date: Nov 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 )

 
Old December 10th, 2003, 12:03 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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.
 
Old December 11th, 2003, 09:09 PM
Authorized User
 
Join Date: Nov 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Service Consuming another web service CraigWhitfield EJB 0 January 10th, 2008 08:38 AM
servlet service() method Nicholsen Servlets 0 January 28th, 2007 09:17 PM
Method calls within same class w/Interface gmontanaro C# 0 April 6th, 2006 05:44 PM
Execute method of web service, about database? hueduongit .NET Web Services 3 December 3rd, 2003 03:18 AM
Object as parameter in a web service method evandro.paula .NET Web Services 3 October 14th, 2003 02:20 PM





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