Webservice with a business object


Author
Message
Ross L Rooker, Sr.(1)
Ross L Rooker, Sr.(1)
StrataFrame User (148 reputation)StrataFrame User (148 reputation)StrataFrame User (148 reputation)StrataFrame User (148 reputation)StrataFrame User (148 reputation)StrataFrame User (148 reputation)StrataFrame User (148 reputation)StrataFrame User (148 reputation)StrataFrame User (148 reputation)
Group: StrataFrame Users
Posts: 50, Visits: 163
Does someone have a sample of using a business object in a webservice?
Tony Charpentier
Tony Charpentier
StrataFrame Beginner (38 reputation)StrataFrame Beginner (38 reputation)StrataFrame Beginner (38 reputation)StrataFrame Beginner (38 reputation)StrataFrame Beginner (38 reputation)StrataFrame Beginner (38 reputation)StrataFrame Beginner (38 reputation)StrataFrame Beginner (38 reputation)StrataFrame Beginner (38 reputation)
Group: StrataFrame Users
Posts: 10, Visits: 81
Hello

I can help you in the webservice ,

what kind of sample , are you waiting ?   a dataset serialize or a simple value  ?

ps : i prefer a json service rest instead of webservice, cause json is more light than xml format, in large data case.
Edited 10 Years Ago by Tony Charpentier
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Ross:

It isn't going to be any different using the BO in a web service.  The only difference is that you will want to setup your data sources in the global.asax

  1. Make sure that you have a global.asax in your web service project, if not, you can just add one through the "Add New Item"

    http://forum.strataframe.net/Uploads/Images/70d5d71e-4d25-4a6f-9836-972a.png
  2. Next, you will want to define your data sources when the application starts up.  The global.asax will have a method called "Application_Start", add your data sources there:

    http://forum.strataframe.net/Uploads/Images/1a8bd454-8c9e-4429-8055-b17c.png
  3. Now you are ready to use your BOs in your project.  First, make sure that you have a reference to the assembly that houses your business objects.  You can do this in a Web Service project or JSON, either one.  If this is your first go around, you may want to use a web service to get your feet wet.  If this isn't going to be really high traffic, then the web service will be fine.  JSON is lighter weight, but there is also more wiring required.

    Note: You can also just create a web handler which can be even lighter weight than JSON.  I have used web handlers for things like activation servers and really high traffic servers.  I create my own EDI format and then serialize it back and forth between the client and server, and you can't get any lighter since I am 100% in control of every byte being transmitted.


  4. Create a new web service (MyWebservice.asmx).  Then create a web method and use your BO:



    [WebMethod]
    public string MyTestWebMethod()
    {
      using(MyBO bo = new MyBO())
      {
         bo.FillWithWhatever();

         //-- Do whatever you need to do

         //-- Return the results
         return bo.MyFullName;
      }
    }



Ross L Rooker, Sr.(1)
Ross L Rooker, Sr.(1)
StrataFrame User (148 reputation)StrataFrame User (148 reputation)StrataFrame User (148 reputation)StrataFrame User (148 reputation)StrataFrame User (148 reputation)StrataFrame User (148 reputation)StrataFrame User (148 reputation)StrataFrame User (148 reputation)StrataFrame User (148 reputation)
Group: StrataFrame Users
Posts: 50, Visits: 163
Thanks Trent. Worked like a charm.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search