ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Web Technologies
    EC-331
    Progress0 / 38 topics
    Topics
    1. Introduction to Web Applications2. TCP/IP Application Services3. Web Servers: Basic Operation4. Web Servers: Virtual Hosting5. Web Servers: Chunked Transfers6. Web Servers: Caching Support7. Web Servers: Extensibility8. SGML9. HTML510. CSS311. XML Languages and Applications: Core XML12. XML Languages and Applications: XHTML13. XML Languages and Applications: XHTML MP14. Web Service: SOAP15. Web Service: REST16. Web Service: WML17. Web Service: XSL18. Web Services: Operations19. Web Services: Processing HTTP Requests20. Web Services: Processing HTTP Responses21. Web Services: Cookie Coordination22. Web Services: Privacy and P3P23. Web Services: Complex HTTP Interactions24. Web Services: Dynamic Content Delivery25. Server Configuration26. Server Security27. Web Browsers Architecture and Processes28. Active Browser Pages: JavaScript29. Active Browser Pages: DHTML30. Active Browser Pages: AJAX31. JSON32. Approaches to Web Application Development33. Programming in Any Scripting Language34. Search Technologies35. Search Engine Optimization36. XML Query Language37. Semantic Web38. Future Web Application Framework
    EC-331›Web Services: Operations
    Web TechnologiesTopic 18 of 38

    Web Services: Operations

    7 minread
    1,139words
    Intermediatelevel

    Web Services: Operations

    In the context of web services, operations refer to the specific functions or actions that a web service can perform when it is invoked by a client. These operations define the interaction between the client and the server, specifying what functionality is offered and how data is processed.

    Web services, whether SOAP-based or RESTful, expose a set of operations to allow clients to request data or perform actions. These operations are defined in service descriptions and are crucial for the client-server communication.

    Key Aspects of Web Services Operations

    1. SOAP-Based Web Services Operations

    In SOAP (Simple Object Access Protocol) web services, operations are defined in the WSDL (Web Services Description Language) document. WSDL serves as the contract between the client and the service, detailing the available operations, their input and output parameters, and the protocols that are supported.

    SOAP Operations typically follow a request-response pattern, where the client sends a request message, and the service responds with a message. Each operation in a SOAP web service corresponds to a specific action that the service can perform.

    Structure of SOAP Operation in WSDL

    In a WSDL file, an operation is defined within the <operation> tag inside the <portType> element. Each operation specifies its request and response messages, which are defined in the <message> element.

    Example of a WSDL operation:

    <definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://example.com/service">
        <portType name="BookService">
            <operation name="GetBookDetails">
                <input message="tns:GetBookDetailsRequest"/>
                <output message="tns:GetBookDetailsResponse"/>
            </operation>
        </portType>
        <binding name="BookServiceSoap" type="tns:BookService">
            <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
            <operation name="GetBookDetails">
                <soap:operation soapAction="http://example.com/GetBookDetails"/>
                <input>
                    <soap:body use="literal"/>
                </input>
                <output>
                    <soap:body use="literal"/>
                </output>
            </operation>
        </binding>
    </definitions>
    
    • Operation Name: The operation is named GetBookDetails and describes a specific action the service can perform (retrieving details about a book).
    • Input and Output: Each operation has defined input and output messages. For GetBookDetails, the request and response are defined in the messages GetBookDetailsRequest and GetBookDetailsResponse.
    Example SOAP Operation (Request-Response)

    When a client invokes a SOAP operation like GetBookDetails, it might send a request message in XML format, such as:

    Request (SOAP Envelope)

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://example.com/service">
        <soapenv:Header/>
        <soapenv:Body>
            <web:GetBookDetails>
                <web:BookID>12345</web:BookID>
            </web:GetBookDetails>
        </soapenv:Body>
    </soapenv:Envelope>
    

    The server processes the request and sends back a response:

    Response (SOAP Envelope)

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://example.com/service">
        <soapenv:Header/>
        <soapenv:Body>
            <web:GetBookDetailsResponse>
                <web:BookTitle>Introduction to Web Services</web:BookTitle>
                <web:Author>John Doe</web:Author>
                <web:Year>2023</web:Year>
            </web:GetBookDetailsResponse>
        </soapenv:Body>
    </soapenv:Envelope>
    

    2. RESTful Web Services Operations

    In REST (Representational State Transfer) web services, operations are mapped to HTTP methods (GET, POST, PUT, DELETE, etc.). Each HTTP method corresponds to a specific CRUD (Create, Read, Update, Delete) operation on the resources exposed by the service.

    REST is stateless, and each operation is performed by sending an HTTP request to a specific URL (or endpoint) that represents a resource. The response can be in various formats, such as XML, JSON, or plain text.

    Common REST Operations
    • GET: Retrieve data from the server (Read).
    • POST: Submit data to be processed by the server (Create).
    • PUT: Update existing data on the server (Update).
    • DELETE: Delete data from the server (Delete).
    Example of REST Operations

    Let's assume you have a RESTful web service for managing books, where each book is identified by a unique ID.

    • GET: Retrieve details of a book

      • Endpoint: /books/{id}
      • Example Request: GET /books/12345
      • Example Response (JSON):
        {
          "bookID": "12345",
          "title": "Introduction to Web Services",
          "author": "John Doe",
          "year": 2023
        }
        
    • POST: Create a new book

      • Endpoint: /books
      • Example Request:
        {
          "title": "Mastering REST",
          "author": "Jane Smith",
          "year": 2024
        }
        
      • Example Response (Status 201 Created):
        {
          "bookID": "67890",
          "title": "Mastering REST",
          "author": "Jane Smith",
          "year": 2024
        }
        
    • PUT: Update an existing book

      • Endpoint: /books/12345
      • Example Request:
        {
          "title": "Introduction to Web Services (Updated)",
          "author": "John Doe",
          "year": 2024
        }
        
      • Example Response (Status 200 OK):
        {
          "bookID": "12345",
          "title": "Introduction to Web Services (Updated)",
          "author": "John Doe",
          "year": 2024
        }
        
    • DELETE: Delete a book

      • Endpoint: /books/12345
      • Example Request: DELETE /books/12345
      • Example Response (Status 204 No Content)

    3. GraphQL Operations

    GraphQL is an alternative approach to traditional REST or SOAP web services. Instead of having predefined endpoints for specific actions (like GET or POST requests), GraphQL exposes a single endpoint that can handle a variety of operations through queries, mutations, and subscriptions.

    • Query: Retrieves data from the server.
    • Mutation: Changes data on the server.
    • Subscription: Enables real-time data updates.
    Example GraphQL Operations
    • Query: To get details of a book by ID
    query {
      book(id: 12345) {
        title
        author
        year
      }
    }
    
    • Mutation: To create a new book
    mutation {
      createBook(title: "New Book", author: "Jane Doe", year: 2024) {
        id
        title
        author
      }
    }
    
    • Subscription: To get real-time updates when a new book is added
    subscription {
      newBook {
        id
        title
      }
    }
    

    Key Features of Web Service Operations

    1. Encapsulation of Functionality: Operations expose specific functionality that clients can invoke remotely, abstracting the underlying implementation.
    2. Interoperability: Operations in web services are designed to work across different platforms, technologies, and programming languages, enabling diverse systems to communicate.
    3. Data Exchange: Web service operations define the format for data exchange, which can range from XML (in SOAP) to JSON (in REST).
    4. Statelessness (in REST): RESTful operations are stateless, meaning each request is independent, and no session information is stored between requests.
    5. Security: Operations often include mechanisms for authentication and authorization, such as API keys in REST or WS-Security in SOAP.

    Conclusion

    Web service operations are the core functions that enable clients to interact with web services. They define the actions that can be performed on the server-side, whether retrieving data, modifying resources, or performing specific business logic. The operation details, including input parameters, output formats, and communication protocols (SOAP, REST, or GraphQL), are key to defining how the client and server communicate in web service-based architectures. Understanding web service operations is essential for designing and consuming effective APIs, ensuring seamless data exchange and application integration.

    Previous topic 17
    Web Service: XSL
    Next topic 19
    Web Services: Processing HTTP Requests

    Past Papers

    Open this section to load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time7 min
      Word count1,139
      Code examples0
      DifficultyIntermediate