Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. exposed items in a web service

exposed items in a web service

Scheduled Pinned Locked Moved C#
questionlearning
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bfis108137
    wrote on last edited by
    #1

    I made a web service and when I went to make the tet client I noticed that the Order Class was exposed which was fine with me except that the Order class comes from the BookStoreBLL reference which I guess is making me wonder if the Order class is exposed then why isn't all of the BookStoreBLL class exposed? And how could I expose at least one more item? And why is the Order class showing up? The following is my main code page for my Web Service.

    using System;
    using System.Data;
    using System.Web;
    using System.Collections;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.ComponentModel;
    using BookStoreBLL;

    namespace WebService1
    {
    /// /// Summary description for Service1
    ///
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    public class Service1 : System.Web.Services.WebService
    {

        \[WebMethod\]
        public string HelloWorld()
        {
            return "Hello World";
        }
        OrderedBooksCollection coll;
        BooksBLL bll;
        UsersBLL userBll;
        OrdersBLL orderBll;
        \[WebMethod\]
        public Book\[\] AllBooks()
        {
            bll = new BooksBLL("C");
            return bll.allBooks();
            
        }
    
        \[WebMethod\]
        public ReturnedOrderInfo ExecuteOrder(User u, Order o)
        {
            ReturnedOrderInfo info = new ReturnedOrderInfo();
            
            info.OrderNumber = 0;
            userBll = new UsersBLL("C");
            UserRoles role = userBll.verifyUser(u.UserName, u.PW);
            if (role == UserRoles.BadPass || role == UserRoles.None || role == UserRoles.NoUsers)
            {
                info.Status = orderStatus.UnauthorizedUser;
                return info;
            }
            //bll = new BooksBLL("C");
            info = orderBll.ProcessOrder(o);
            return info;
        }
    
    
    
    }
    

    }

    S 1 Reply Last reply
    0
    • B bfis108137

      I made a web service and when I went to make the tet client I noticed that the Order Class was exposed which was fine with me except that the Order class comes from the BookStoreBLL reference which I guess is making me wonder if the Order class is exposed then why isn't all of the BookStoreBLL class exposed? And how could I expose at least one more item? And why is the Order class showing up? The following is my main code page for my Web Service.

      using System;
      using System.Data;
      using System.Web;
      using System.Collections;
      using System.Web.Services;
      using System.Web.Services.Protocols;
      using System.ComponentModel;
      using BookStoreBLL;

      namespace WebService1
      {
      /// /// Summary description for Service1
      ///
      [WebService(Namespace = "http://tempuri.org/")]
      [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
      [ToolboxItem(false)]
      public class Service1 : System.Web.Services.WebService
      {

          \[WebMethod\]
          public string HelloWorld()
          {
              return "Hello World";
          }
          OrderedBooksCollection coll;
          BooksBLL bll;
          UsersBLL userBll;
          OrdersBLL orderBll;
          \[WebMethod\]
          public Book\[\] AllBooks()
          {
              bll = new BooksBLL("C");
              return bll.allBooks();
              
          }
      
          \[WebMethod\]
          public ReturnedOrderInfo ExecuteOrder(User u, Order o)
          {
              ReturnedOrderInfo info = new ReturnedOrderInfo();
              
              info.OrderNumber = 0;
              userBll = new UsersBLL("C");
              UserRoles role = userBll.verifyUser(u.UserName, u.PW);
              if (role == UserRoles.BadPass || role == UserRoles.None || role == UserRoles.NoUsers)
              {
                  info.Status = orderStatus.UnauthorizedUser;
                  return info;
              }
              //bll = new BooksBLL("C");
              info = orderBll.ProcessOrder(o);
              return info;
          }
      
      
      
      }
      

      }

      S Offline
      S Offline
      SeMartens
      wrote on last edited by
      #2

      Hi, I think this has something to do with the arguments the method ExecuteOrder is expecting. Since the method needs an object from type "order" your client has to pass it. So Order is exposed. Also the ReturnedOrderInfo, Book and User classes should be exposed. These are not really the classes you have in your BooksBLL. The service does nothing else than mapping the XML to objects from the expected type. The client only has stubs that generate these XML. You will see that your Order-object at the client doesn't expose the methods you declared in the class on your server. Regards Sebastian

      It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups