Development Web Services SOAP.txt

Card Set Information

Development Web Services SOAP.txt
2014-03-31 15:36:17
Software Development Web Services SOAP
Software Development Web Services SOAP
Software Development Web Services SOAP
Show Answers:

  1. What is a web service?
    Web services are components on a Web server that a client application can call by making HTTP requests across the Web. ASP.NET enables you to create custom Web services or to use built-in application services, and to call these services from any client application. The final product created is a DLL assembly which can then be placed in IIS and made consumable by client applications.
  2. As a client consuming a web service, how do you determine the structure of a web service?
    The web service structure is exposed using the Web Service Description Language (WSDL), an XML document describing the attributes and interfaces of the web service. This file usually is named the same as the web service, is found in the same directory, and contains the .DISCO file extension for client discovery.
  3. How do you deploy a web service?
    Nothing abnormal, simply place your .asmx and .disco files into their intended directory, just as you would any .aspx file.
  4. Quickly, explain SOAP vs REST.
    REST is an architecture. REST will give human-readable results. REST is stateless. REST services are easily cacheable and is smaller and faster than SOAP. SOAP is a protocol. It can run on top of other protocols such as SMTP, FTP, HTTP, etc.
  5. What are the parts of a basic SOAP message?
    An envelope which includes a header and a body.
  6. What are the most basic sections of a web service?
    (a) declaration [WebService(Namespace="")] (b) using namespaces (c) WebService attribute with namespace (d) class which inherits WebService, (d) and various methods, either private or public (public have the WebMethod across the top which means it can be consumed): [ WebMethod(Description="Obtains the Server Machine Name", EnableSession=true)]
  7. What files get created when you build a simple Math web service in .NET called MyWebService?
    (a) bin\MyWebService.dll which is the web service itself, (b) MyWebService.asmx which is your web service URL, navigate to this file in a browser and you'll get back a page showing available methods and required parameters along with the links to test the service out, (c) contains version and configuration info for your assembly (dll), (d) web.config which will contain run information such as debug options, use of cookies, etc. (e) MyWebService.cs class file containing the code you are exposing along with the namespace, and (f) global.asax, the ASP.NET equivalent of a standard global.asa file.
  8. What is the first line of code on a web service?
    <%@ WebService Language="C#" class="SecurityWebService" %>
  9. What name space do you use for a web service?
    Using System.Web.Services;
  10. Do web services use inheritance?
    Yes, ANY class contained in a web service must inherit from the WebService class, for example, public class MyWebService: WebService.
  11. Web services can contain important, proprietary data and business logic. Since they are accessible and searchable by anyone on the web, how do you prevent others from seeing this information?
    Your web service interface methods will all have the WebMethod(Description="", EnableSession=false)] headers, others would be private so they won't show to consumers.
  12. What is REST?
    REST stands for REpresentational State Transfer which, unlike SOAP, is not a protocol but an architectural style.
  13. What is SOAP?
    Simple Object Access Protocol (SOAP) is a strongly-typed XML based messaging protocol created by Microsoft and largely replaced by REST. SOAP is a way for a program running in one kind of OS to communicate with a program in the same or different OS using HTTP and XML. Developed by Microsoft, it specifies exactly how to encode an HTTP header and XML file so that communication between two systems can occur. As an example, a SOAP message could be sent to a website with various parameters (city name, zipcode, price, home size) for a search. The site would then process the requests and return an XML-formatted document with resulting data (prices, locations, features, etc.). With this information being returned back, the original party could parse this information for display to the user. Examples would include Google Weather, Analytics, an RSS Feed, or Zillow.
  14. Which is a better to use, REST or SOAP services?
    Depends on the objective. SOAP is more heavy-duty, can be used on multiple systems such as HTTP, TCP, SMTP and others, is strongly-typed, can have state implementation details, and is standardized so has better adoption across firewalls, proxies, and other standardized implementations. REST is smaller and simpler to use, has been adopted over SOAP in most applications, works well on mobile devices and PDA's, is stateless, is not type-safe, can output XML or other languages.
  15. Once a web service has been created, how would you call it from another application?
    In the Project icon, you would select 'Add Web Reference' and supply the necessary URL to the new web service. Finally, in the code behind, you would need to create two lines of code: (1) MyService.Service1 service = new MyService.Service1(); (b) string message = service.HelloWorld();
  16. Write a super simple web service that displays 'Hello World', starting from namespace.
    namespace MyService{[WebService(Namespace="someurl",Description="example")] public class WebService1 : System.Web.Services.WebService{[WebMethod] public string HelloWorld(){return "Hello World"; }}}
  17. Typically, a web service is hosted locally for testing purposes. What would the URL be in this case?
  18. How do you test a web service?
    Open the .asmx file in a browser which will show all public methods and parameters (if needed)
  19. How would you consume a simple web service in C#?
    (1) MyService.Service1 service = new MyService.Service1(); (b) string message = service.HelloWorld();