custom types: classes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris

    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(stri ng id) { firstID= id; }

    public void setSecondID(str ing id) { secondID= id; }

    }

    [WebMethod]

    public bool GetResellerList 2(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

    #2
    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.Diagnost ics.DebuggerSte pThroughAttribu te()]

    [System.Componen tModel.Designer CategoryAttribu te("code")]

    [System.Web.Serv ices.WebService BindingAttribut e(Name="LiveUpd ateSoap",
    Namespace="http ://orama-tech.gr/WebServices/")]

    public class LiveUpdate :
    System.Web.Serv ices.Protocols. SoapHttpClientP rotocol {

    }


    /// <remarks/>

    ///Custom class

    /// <remarks/>

    [System.Xml.Seri alization.XmlTy peAttribute(Nam espace="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" <chris@no-spam.com> wrote in message
    news:eNC$EZodFH A.688@TK2MSFTNG P14.phx.gbl...[color=blue]
    > 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(stri ng id) { firstID= id; }
    >
    > public void setSecondID(str ing id) { secondID= id; }
    >
    > }
    >
    > [WebMethod]
    >
    > public bool GetResellerList 2(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
    >
    >[/color]


    Comment

    • Nassos

      #3
      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.Diagnost ics.DebuggerSte pThroughAttribu te()]

      [System.Componen tModel.Designer CategoryAttribu te("code")]

      [System.Web.Serv ices.WebService BindingAttribut e(Name="LiveUpd ateSoap",
      Namespace="http ://orama-tech.gr/WebServices/")]

      public class LiveUpdate :
      System.Web.Serv ices.Protocols. SoapHttpClientP rotocol {

      }


      /// <remarks/>

      ///Custom class

      /// <remarks/>

      [System.Xml.Seri alization.XmlTy peAttribute(Nam espace="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" <chris@no-spam.com> wrote in message
      news:eNC$EZodFH A.688@TK2MSFTNG P14.phx.gbl...[color=blue]
      > 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(stri ng id) { firstID= id; }
      >
      > public void setSecondID(str ing id) { secondID= id; }
      >
      > }
      >
      > [WebMethod]
      >
      > public bool GetResellerList 2(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
      >
      >[/color]


      Comment

      • Nassos

        #4
        Re: custom types: classes

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

        [System.Xml.Seri alization.XmlTy peAttribute(Nam espace="http://orama-tech.gr/WebServices/")]

        public class Token
        {

        private string firstID;

        private string secondID;

        public string getFirstD() ;

        public string getSecondID() ;

        public void setFirstID(stri ng id) ;
        public void setSecondID(str ing id) ;
        }


        "Chris" <chris@no-spam.com> wrote in message
        news:eNC$EZodFH A.688@TK2MSFTNG P14.phx.gbl...[color=blue]
        > 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(stri ng id) { firstID= id; }
        >
        > public void setSecondID(str ing id) { secondID= id; }
        >
        > }
        >
        > [WebMethod]
        >
        > public bool GetResellerList 2(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
        >
        >[/color]


        Comment

        • Nassos

          #5
          Re: custom types: classes

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

          [System.Xml.Seri alization.XmlTy peAttribute(Nam espace="http://orama-tech.gr/WebServices/")]

          public class Token
          {

          private string firstID;

          private string secondID;

          public string getFirstD() ;

          public string getSecondID() ;

          public void setFirstID(stri ng id) ;
          public void setSecondID(str ing id) ;
          }


          "Chris" <chris@no-spam.com> wrote in message
          news:eNC$EZodFH A.688@TK2MSFTNG P14.phx.gbl...[color=blue]
          > 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(stri ng id) { firstID= id; }
          >
          > public void setSecondID(str ing id) { secondID= id; }
          >
          > }
          >
          > [WebMethod]
          >
          > public bool GetResellerList 2(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
          >
          >[/color]


          Comment

          • Marvin Smit

            #6
            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" <chris@no-spam.com> wrote:
            [color=blue]
            >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(stri ng id) { firstID= id; }
            >
            >public void setSecondID(str ing id) { secondID= id; }
            >
            >}
            >
            >[WebMethod]
            >
            >public bool GetResellerList 2(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
            >[/color]

            Comment

            • Marvin Smit

              #7
              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" <chris@no-spam.com> wrote:
              [color=blue]
              >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(stri ng id) { firstID= id; }
              >
              >public void setSecondID(str ing id) { secondID= id; }
              >
              >}
              >
              >[WebMethod]
              >
              >public bool GetResellerList 2(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
              >[/color]

              Comment

              • Chris

                #8
                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@gm ail.com> wrote in message
                news:do2lb1127t c63hefe3c5t6l9f 5tttqmm2h@4ax.c om...[color=blue]
                > 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" <chris@no-spam.com> wrote:
                >[color=green]
                > >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(stri ng id) { firstID= id; }
                > >
                > >public void setSecondID(str ing id) { secondID= id; }
                > >
                > >}
                > >
                > >[WebMethod]
                > >
                > >public bool GetResellerList 2(Token token, string languageisocode )
                > >
                > >{
                > >
                > >return true;
                > >
                > >}
                > >
                > >
                > >When I view the object on the client side, I can't see any of the[/color][/color]
                properties[color=blue][color=green]
                > >or methods defined in the Token class. What am I missing?
                > >
                > >Thanks,
                > >
                > >Chris
                > >[/color]
                >[/color]


                Comment

                • Chris

                  #9
                  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@gm ail.com> wrote in message
                  news:do2lb1127t c63hefe3c5t6l9f 5tttqmm2h@4ax.c om...[color=blue]
                  > 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" <chris@no-spam.com> wrote:
                  >[color=green]
                  > >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(stri ng id) { firstID= id; }
                  > >
                  > >public void setSecondID(str ing id) { secondID= id; }
                  > >
                  > >}
                  > >
                  > >[WebMethod]
                  > >
                  > >public bool GetResellerList 2(Token token, string languageisocode )
                  > >
                  > >{
                  > >
                  > >return true;
                  > >
                  > >}
                  > >
                  > >
                  > >When I view the object on the client side, I can't see any of the[/color][/color]
                  properties[color=blue][color=green]
                  > >or methods defined in the Token class. What am I missing?
                  > >
                  > >Thanks,
                  > >
                  > >Chris
                  > >[/color]
                  >[/color]


                  Comment

                  • Chris

                    #10
                    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" <nasos@orama-tech.gr> wrote in message
                    news:%23gDZZSyd FHA.3836@tk2msf tngp13.phx.gbl. ..[color=blue]
                    > So put in the Reference.cs the following:
                    > /// <remarks/>
                    >
                    >[/color]
                    [System.Xml.Seri alization.XmlTy peAttribute(Nam espace="http://orama-tech.gr/W
                    ebServices/")][color=blue]
                    >
                    > public class Token
                    > {
                    >
                    > private string firstID;
                    >
                    > private string secondID;
                    >
                    > public string getFirstD() ;
                    >
                    > public string getSecondID() ;
                    >
                    > public void setFirstID(stri ng id) ;
                    > public void setSecondID(str ing id) ;
                    > }
                    >
                    >
                    > "Chris" <chris@no-spam.com> wrote in message
                    > news:eNC$EZodFH A.688@TK2MSFTNG P14.phx.gbl...[color=green]
                    > > 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(stri ng id) { firstID= id; }
                    > >
                    > > public void setSecondID(str ing id) { secondID= id; }
                    > >
                    > > }
                    > >
                    > > [WebMethod]
                    > >
                    > > public bool GetResellerList 2(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
                    > >
                    > >[/color]
                    >
                    >[/color]


                    Comment

                    • Chris

                      #11
                      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" <nasos@orama-tech.gr> wrote in message
                      news:%23gDZZSyd FHA.3836@tk2msf tngp13.phx.gbl. ..[color=blue]
                      > So put in the Reference.cs the following:
                      > /// <remarks/>
                      >
                      >[/color]
                      [System.Xml.Seri alization.XmlTy peAttribute(Nam espace="http://orama-tech.gr/W
                      ebServices/")][color=blue]
                      >
                      > public class Token
                      > {
                      >
                      > private string firstID;
                      >
                      > private string secondID;
                      >
                      > public string getFirstD() ;
                      >
                      > public string getSecondID() ;
                      >
                      > public void setFirstID(stri ng id) ;
                      > public void setSecondID(str ing id) ;
                      > }
                      >
                      >
                      > "Chris" <chris@no-spam.com> wrote in message
                      > news:eNC$EZodFH A.688@TK2MSFTNG P14.phx.gbl...[color=green]
                      > > 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(stri ng id) { firstID= id; }
                      > >
                      > > public void setSecondID(str ing id) { secondID= id; }
                      > >
                      > > }
                      > >
                      > > [WebMethod]
                      > >
                      > > public bool GetResellerList 2(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
                      > >
                      > >[/color]
                      >
                      >[/color]


                      Comment

                      Working...