web services i returning data in xml format
Download
Skip this Video
Download Presentation
Web Services I: Returning Data in XML Format

Loading in 2 Seconds...

play fullscreen
1 / 10

Web Services I: Returning Data in XML Format - PowerPoint PPT Presentation


  • 75 Views
  • Uploaded on

Web Services I: Returning Data in XML Format. Service-Oriented Architecture (SOA). Old Model for Applications Executables running on individual computers Limited or no ability to communicate between applications Very dependent on platform, OS and/or programming language SOA

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Web Services I: Returning Data in XML Format' - yuli-hooper


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
service oriented architecture soa
Service-Oriented Architecture (SOA)
  • Old Model for Applications
    • Executables running on individual computers
    • Limited or no ability to communicate between applications
    • Very dependent on platform, OS and/or programming language
  • SOA
    • Loosely coupled “Services”
      • Currently – Web Services
    • Can be called from multiple platforms, OS’s and languages
web service
Web Service
  • A class with methods that can be accessed (via the Internet):
    • From different platforms (Hardware and OS)
    • By different programming languages
  • Information is returned from the Web Service in an XML format or JSON format
i creating a hello world web service with vs 2010
I. Creating a "Hello World" Web Service with VS 2010
  • Within a Visual Studio 2010 Website
  • Website, Add New Item, Web Service
    • This will create a class with all of the unique web service stuff already in it – including a “Hello World” test method.
    • The web service by default will have two files (just like our web pages):
      • .asmx file (WebService.asmx)
        • This is what you point the users of the service at
        • It contains a link to the .cs file (below)
      • .cs class file (WebService.cs)
        • Lives in the App_Code folder
  • Browse .asxm file to test the Web Service
hello world part 2
"Hello World" part 2
  • Here is the code in the WebService.asmx file

<%@ WebServiceLanguage="C#"CodeBehind="~/App_Code/WebService.cs"Class="WebService" %>

This is the file that is browsed,

It is essentially just a front-end to the .cs file behind it.

hello world part 3
"Hello World" part 3

[WebService(Namespace = "http://tempuri.org/")]

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the //following line.

// [System.Web.Script.Services.ScriptService]

public classWebService : System.Web.Services.WebService {

public WebService () {

//Uncomment the following line if using designed components

//InitializeComponent();

}

[WebMethod]

public stringHelloWorld() {

return "Hello World";

}

}

  • Here is the code in the WebService.cs file
i providing a web service cont adding methods
I. Providing a Web Service cont: Adding Methods
  • Adding a method to a Web Service is identical to what you’re used to, except:
    • [WebMethod] attribute must be immediately before the public keyword in the method declaration

[WebMethod]public decimal CalculateYearlyBonus(decimal parYearlySales){

}

ws musiccategories
WS_MusicCategories

[WebService(Namespace = "http://tempuri.org/")]

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

// To allow this Web Service to be called from script, using ASP.NET //AJAX, uncomment the following line.

// [System.Web.Script.Services.ScriptService]

public classWebService : System.Web.Services.WebService {

publicWS_MusicCategories () {

//Uncomment the following line if using designed components

//InitializeComponent();

}

[WebMethod]

public List<TO_MusicCategory>GetCategories() {

DA_MusicCategoriescategoriesObject = new DA_MusicCategories();

returncategoriesObject.GetCategories()";

}

}

ws musiccategories cont
WS_MusicCategories cont.
  • From the preceding slide, note the following:
    • The [ScriptService] line is uncommented
    • All the GetCategories web service method does is:
      • Create an instance of your DA_MusicCategories class
      • Calls the DA class method GetCategories
      • Returns the result of that call
    • The Web Service is just a wrapper around your original DA class that allows it to be used as a web service.
ad