Blog
Web Services Past Paper 2016 – BSIT 7th Term UOS (SE-493)
University of Sargodha Web Services (SE-493) paper for BS IT 7th term, 2016 exam (80 marks, 2:30 hours). The paper has been retyped, and solved answers are given below for all 16 short questions and all six long questions on SOAP, REST, WSDL, DISCO and accessing a class as a web service.
Solved answers
Q1 – Short answers (16 × 2)
i. Web services: Software components that let applications communicate over a network (usually HTTP) using standard formats such as XML/JSON, independent of platform and language, e.g. a weather service called by a mobile app.
ii. SOA vs web service: SOA (Service-Oriented Architecture) is an architectural style of building systems from loosely coupled, reusable services. A web service is one technology to implement a service in SOA using web standards (SOAP/WSDL/REST).
iii. SOAP: Simple Object Access Protocol – an XML-based messaging protocol for exchanging structured information between web services, usually over HTTP; messages have an Envelope, optional Header and Body.
iv. REST: Representational State Transfer – an architectural style where resources are identified by URIs and manipulated with standard HTTP methods (GET, POST, PUT, DELETE); it is stateless and usually uses JSON or XML.
v. REST vs SOAP web service: SOAP is a protocol with strict XML envelope, WSDL contract and WS-* standards (security, transactions); heavier. REST is an architectural style using plain HTTP, URIs and lightweight formats (JSON), cacheable, simpler and faster.
vi. Can SOAP messages have attachments? Yes – using SOAP with Attachments (MIME multipart), MTOM/XOP (optimised binary attachments) or DIME.
vii. SOAP Envelope element: The root element of every SOAP message; it defines the XML document as a SOAP message and declares namespaces. It contains an optional Header and a mandatory Body.
viii. XML: eXtensible Markup Language – a text-based markup language for storing and transporting data with user-defined tags; it is self-describing and platform independent.
ix. XML Schema: An XML-based language (XSD) that defines the structure of an XML document – allowed elements, attributes, their order and data types – used to validate documents.
x. XML application: A markup language defined using XML rules for a specific domain, e.g. XHTML, SVG, MathML, RSS, WSDL and SOAP.
xi. Basic web-service security issues: Authentication, authorisation, confidentiality (encryption), integrity (signing), non-repudiation, and attacks such as XML injection, replay and denial of service. (Handled by WS-Security, SSL/TLS, OAuth.)
xii. SOAP client: A program that creates SOAP request messages, sends them to a web service endpoint and processes the SOAP responses – often generated automatically from the WSDL (proxy/stub).
xiii. How to read WSDL files: Open the URL (e.g. service?wsdl) in a browser or XML editor, or use tools such as wsimport, wsdl.exe, SoapUI or “Add Service Reference” in Visual Studio, which parse the WSDL and generate client proxy classes.
xiv. Encoding rules for header entries: Each header entry is an immediate child of the SOAP Header, must be namespace-qualified, and may carry attributes such as mustUnderstand (receiver must process it) and actor/role (which node should process it), and encodingStyle.
xv. HTTP methods supported by REST: GET (read), POST (create), PUT (update/replace), PATCH (partial update), DELETE (remove); also HEAD and OPTIONS.
xvi. Client-side vs server-side web services: Server-side: the service is hosted on a server and exposes operations (provider). Client-side: the application (consumer) that calls the service, e.g. a browser/JavaScript or mobile app making requests.
Q2 – DISCO
DISCO (Discovery of Web Services) is a Microsoft specification for discovering web services available on a particular server. A .disco (XML) file lists links to the WSDL documents (service descriptions) and other discovery documents on that server. A client or tool (e.g. disco.exe or “Add Web Reference” in Visual Studio) reads it to find which services exist and where their contracts are. Unlike UDDI, which is a global registry, DISCO is used for discovery on a known server.
Q3 – Components published when deploying a web service
- The web service implementation (e.g. .asmx file / compiled classes or JAR/WAR) on the web server.
- The WSDL service description that defines operations, messages, data types, binding and endpoint address.
- The endpoint URL where the service is hosted.
- Optional discovery documents (DISCO) and registration in a UDDI registry so clients can find it.
- Configuration files (web.config / web.xml) and security settings.
Q4 – Steps performed by the client to access a web service
- Discover the service (UDDI/DISCO or known URL).
- Obtain and read the WSDL to know operations, parameters and endpoint.
- Generate a proxy/stub class from the WSDL (or build HTTP requests manually).
- Create a request: the proxy serialises method calls into a SOAP/XML (or REST/JSON) message.
- Send the request over HTTP to the endpoint.
- The service processes it and returns a response message.
- The client deserialises the response and uses the result; handle faults/errors.
Q5 – Drawbacks of using GET and POST
- GET: parameters are visible in the URL (not secure, stored in logs and history); URL length is limited, so large data cannot be sent; only simple name-value pairs (no complex types/objects); can be cached unintentionally.
- POST: data is in the body but still plain text unless HTTPS is used; not cacheable or bookmarkable; still limited to simple name-value types in classic HTTP-GET/POST bindings.
- Both cannot carry SOAP headers, so WS-Security, transactions and other SOAP features are unavailable; no strong typing or contract like SOAP/WSDL.
Q6 – Accessing a class as a web service
In .NET (ASMX): derive the class from System.Web.Services.WebService, add the [WebService] attribute to the class and [WebMethod] to each public method to be exposed, and place it in an .asmx file on IIS. In Java (JAX-WS): annotate the class with @WebService and methods with @WebMethod and publish it (Endpoint.publish or deploy on a server). The framework generates the WSDL and handles SOAP serialisation; clients then call the methods through a proxy.
[WebService(Namespace = "http://example.org/")]
public class Calculator : WebService {
[WebMethod]
public int Add(int a, int b) { return a + b; }
}Q7 – Different kinds of web services
- SOAP web services (XML, WSDL, WS-*).
- RESTful web services (HTTP + JSON/XML).
- XML-RPC and JSON-RPC (simple remote procedure calls).
- GraphQL and gRPC (modern API styles).
- By function: data services, business/process services, utility services, and composite (orchestrated) services.
