Professional Web Applications Themes

custom types: classes - ASP.NET Web Services

Hi, I'm new to web services and I'm having some trouble figuring out how to define a custom object that works through the webservice. For example, I have the following on the server side: public class Token { private string firstID; private string secondID; public string getFirstD() { return firstID; } public string getSecondID() { return secondID; } public void setFirstID(string id) { firstID= id; } public void setSecondID(string id) { secondID= id; } } [WebMethod] public bool GetResellerList2(Token token, string languageisocode) { return true; } When I view the object on the client side, I can't see any of ...

  1. #1

    Default custom types: classes

    Hi,

    I'm new to web services and I'm having some trouble figuring out how to
    define a custom object that works through the webservice.

    For example, I have the following on the server side:

    public class Token
    {

    private string firstID;

    private string secondID;

    public string getFirstD() { return firstID; }

    public string getSecondID() { return secondID; }

    public void setFirstID(string id) { firstID= id; }

    public void setSecondID(string id) { secondID= id; }

    }

    [WebMethod]

    public bool GetResellerList2(Token token, string languageisocode)

    {

    return true;

    }


    When I view the object on the client side, I can't see any of the properties
    or methods defined in the Token class. What am I missing?

    Thanks,

    Chris


    Chris Guest

  2. #2

    Default Re: custom types: classes

    Hi Chris,
    if inside the asmx file of the ws do not use the custom class it did not
    publish it. to check if it is published go to the web reference of the
    project that you reference the ws and press "show all files"
    expand the reference of the ws and expand the Reference.map in there it is a
    Reference.cs open it, if your custom class is not in there
    /// <remarks/>Web Service Class

    [System.Diagnostics.DebuggerStepThroughAttribute()]

    [System.ComponentModel.DesignerCategoryAttribute("c ode")]

    [System.Web.Services.WebServiceBindingAttribute(Nam e="LiveUpdateSoap",
    Namespace="http://orama-tech.gr/WebServices/")]

    public class LiveUpdate :
    System.Web.Services.Protocols.SoapHttpClientProtoc ol {

    }


    /// <remarks/>

    ///Custom class

    /// <remarks/>

    [System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://localhost/WebServices/")]

    public class DownloadInfo {

    }
    as the ws class
    then you can do anything with it. You can add in the Reference.cs
    programmably.
    Hope that Helps.
    "Chris" <chrisno-spam.com> wrote in message
    news:eNC$EZodFHA.688TK2MSFTNGP14.phx.gbl...
    > Hi,
    >
    > I'm new to web services and I'm having some trouble figuring out how to
    > define a custom object that works through the webservice.
    >
    > For example, I have the following on the server side:
    >
    > public class Token
    > {
    >
    > private string firstID;
    >
    > private string secondID;
    >
    > public string getFirstD() { return firstID; }
    >
    > public string getSecondID() { return secondID; }
    >
    > public void setFirstID(string id) { firstID= id; }
    >
    > public void setSecondID(string id) { secondID= id; }
    >
    > }
    >
    > [WebMethod]
    >
    > public bool GetResellerList2(Token token, string languageisocode)
    >
    > {
    >
    > return true;
    >
    > }
    >
    >
    > When I view the object on the client side, I can't see any of the
    > properties
    > or methods defined in the Token class. What am I missing?
    >
    > Thanks,
    >
    > Chris
    >
    >

    Nassos Guest

  3. #3

    Default Re: custom types: classes

    So put in the Reference.cs the following:
    /// <remarks/>

    [System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://orama-tech.gr/WebServices/")]

    public class Token
    {

    private string firstID;

    private string secondID;

    public string getFirstD() ;

    public string getSecondID() ;

    public void setFirstID(string id) ;
    public void setSecondID(string id) ;
    }


    "Chris" <chrisno-spam.com> wrote in message
    news:eNC$EZodFHA.688TK2MSFTNGP14.phx.gbl...
    > Hi,
    >
    > I'm new to web services and I'm having some trouble figuring out how to
    > define a custom object that works through the webservice.
    >
    > For example, I have the following on the server side:
    >
    > public class Token
    > {
    >
    > private string firstID;
    >
    > private string secondID;
    >
    > public string getFirstD() { return firstID; }
    >
    > public string getSecondID() { return secondID; }
    >
    > public void setFirstID(string id) { firstID= id; }
    >
    > public void setSecondID(string id) { secondID= id; }
    >
    > }
    >
    > [WebMethod]
    >
    > public bool GetResellerList2(Token token, string languageisocode)
    >
    > {
    >
    > return true;
    >
    > }
    >
    >
    > When I view the object on the client side, I can't see any of the
    > properties
    > or methods defined in the Token class. What am I missing?
    >
    > Thanks,
    >
    > Chris
    >
    >

    Nassos Guest

  4. #4

    Default Re: custom types: classes

    Hi,

    ehhh... Web Services expose the public properties and WebMethod
    annotated functions.

    Since you use "Token" as a parameter, and the "Token" class only
    contains private properties (don't get serialized) and public methods!
    nothing of this class will be available in the WebService call.

    if you change you data-class as follows

    public class Token
    {
    private string firstID;
    private string lastID;

    public string FirstID
    {
    get
    {
    return firstID;
    }

    set
    {
    firstID = value;
    }
    }

    public string LastID
    {
    get
    {
    return lastID;
    }

    set
    {
    lastID = value;
    }
    }

    }


    and use that in your WebService you'll see the availability of
    "FirstID" and "LastID" within the generated proxy of this service on
    the client side.


    Hope this helps,

    Marvin Smit



    On Tue, 21 Jun 2005 10:25:48 -0700, "Chris" <chrisno-spam.com> wrote:
    >Hi,
    >
    >I'm new to web services and I'm having some trouble figuring out how to
    >define a custom object that works through the webservice.
    >
    >For example, I have the following on the server side:
    >
    >public class Token
    >{
    >
    >private string firstID;
    >
    >private string secondID;
    >
    >public string getFirstD() { return firstID; }
    >
    >public string getSecondID() { return secondID; }
    >
    >public void setFirstID(string id) { firstID= id; }
    >
    >public void setSecondID(string id) { secondID= id; }
    >
    >}
    >
    >[WebMethod]
    >
    >public bool GetResellerList2(Token token, string languageisocode)
    >
    >{
    >
    >return true;
    >
    >}
    >
    >
    >When I view the object on the client side, I can't see any of the properties
    >or methods defined in the Token class. What am I missing?
    >
    >Thanks,
    >
    >Chris
    >
    Marvin Smit Guest

  5. #5

    Default Re: custom types: classes

    Hmm ... what if I wanted the actual method calls rather than property
    getters? I'm currently mocking out a temporary .net webservice.
    Unfortunately, when it makes it into production, it will be a Java based
    webservice where we'll be doing method calls on custom objects provided by
    the webservice. I just want to mimic the same functionality here and I
    don't think properties are going to work ... is there another solution?

    Thanks,

    Chris


    "Marvin Smit" <marvin.smit> wrote in message
    news:do2lb1127tc63hefe3c5t6l9f5tttqmm2h4ax.com...
    > Hi,
    >
    > ehhh... Web Services expose the public properties and WebMethod
    > annotated functions.
    >
    > Since you use "Token" as a parameter, and the "Token" class only
    > contains private properties (don't get serialized) and public methods!
    > nothing of this class will be available in the WebService call.
    >
    > if you change you data-class as follows
    >
    > public class Token
    > {
    > private string firstID;
    > private string lastID;
    >
    > public string FirstID
    > {
    > get
    > {
    > return firstID;
    > }
    >
    > set
    > {
    > firstID = value;
    > }
    > }
    >
    > public string LastID
    > {
    > get
    > {
    > return lastID;
    > }
    >
    > set
    > {
    > lastID = value;
    > }
    > }
    >
    > }
    >
    >
    > and use that in your WebService you'll see the availability of
    > "FirstID" and "LastID" within the generated proxy of this service on
    > the client side.
    >
    >
    > Hope this helps,
    >
    > Marvin Smit
    >
    >
    >
    > On Tue, 21 Jun 2005 10:25:48 -0700, "Chris" <chrisno-spam.com> wrote:
    >
    > >Hi,
    > >
    > >I'm new to web services and I'm having some trouble figuring out how to
    > >define a custom object that works through the webservice.
    > >
    > >For example, I have the following on the server side:
    > >
    > >public class Token
    > >{
    > >
    > >private string firstID;
    > >
    > >private string secondID;
    > >
    > >public string getFirstD() { return firstID; }
    > >
    > >public string getSecondID() { return secondID; }
    > >
    > >public void setFirstID(string id) { firstID= id; }
    > >
    > >public void setSecondID(string id) { secondID= id; }
    > >
    > >}
    > >
    > >[WebMethod]
    > >
    > >public bool GetResellerList2(Token token, string languageisocode)
    > >
    > >{
    > >
    > >return true;
    > >
    > >}
    > >
    > >
    > >When I view the object on the client side, I can't see any of the
    properties
    > >or methods defined in the Token class. What am I missing?
    > >
    > >Thanks,
    > >
    > >Chris
    > >
    >

    Chris Guest

  6. #6

    Default Re: custom types: classes

    Hmm ... I see what you mean, but if I add this class to References.cs, it's
    added on the client side. Everytime I update the web reference, the changes
    that were made would disappear. Is there any way to ensure that the methods
    get published on the server side?

    Chris

    "Nassos" <nasosorama-tech.gr> wrote in message
    news:%23gDZZSydFHA.3836tk2msftngp13.phx.gbl...
    > So put in the Reference.cs the following:
    > /// <remarks/>
    >
    >
    [System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://orama-tech.gr/W
    ebServices/")]
    >
    > public class Token
    > {
    >
    > private string firstID;
    >
    > private string secondID;
    >
    > public string getFirstD() ;
    >
    > public string getSecondID() ;
    >
    > public void setFirstID(string id) ;
    > public void setSecondID(string id) ;
    > }
    >
    >
    > "Chris" <chrisno-spam.com> wrote in message
    > news:eNC$EZodFHA.688TK2MSFTNGP14.phx.gbl...
    > > Hi,
    > >
    > > I'm new to web services and I'm having some trouble figuring out how to
    > > define a custom object that works through the webservice.
    > >
    > > For example, I have the following on the server side:
    > >
    > > public class Token
    > > {
    > >
    > > private string firstID;
    > >
    > > private string secondID;
    > >
    > > public string getFirstD() { return firstID; }
    > >
    > > public string getSecondID() { return secondID; }
    > >
    > > public void setFirstID(string id) { firstID= id; }
    > >
    > > public void setSecondID(string id) { secondID= id; }
    > >
    > > }
    > >
    > > [WebMethod]
    > >
    > > public bool GetResellerList2(Token token, string languageisocode)
    > >
    > > {
    > >
    > > return true;
    > >
    > > }
    > >
    > >
    > > When I view the object on the client side, I can't see any of the
    > > properties
    > > or methods defined in the Token class. What am I missing?
    > >
    > > Thanks,
    > >
    > > Chris
    > >
    > >
    >
    >

    Chris Guest

Similar Threads

  1. casting custom classes
    By Sam in forum ASP.NET Building Controls
    Replies: 2
    Last Post: July 27th, 09:50 AM
  2. Custom classes with web services
    By Chris Dunaway in forum ASP.NET Web Services
    Replies: 3
    Last Post: December 2nd, 12:52 AM
  3. Events in Custom Controls and Sub Classes
    By Reiner Max in forum ASP.NET Building Controls
    Replies: 1
    Last Post: June 15th, 12:14 PM
  4. Creating custom classes
    By Pea in forum Macromedia Flash Actionscript
    Replies: 0
    Last Post: March 4th, 07:14 AM
  5. Custom Classes with loadmovie, help!
    By The dedicated lad webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 2
    Last Post: February 5th, 10:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139