Câu hỏi phỏng vấn API Design
Câu hỏi

Mention what is the difference between RPC or document style web services? How you determine to
which one to choose?

Câu trả lời

The difference between RPC (Remote Procedure Call) and Document style web services primarily lies in how the SOAP messages are structured and processed. Here is a detailed comparison:

RPC Style Web Services

  1. Message Structure:

    • RPC style web services use the names of the method and its parameters to generate XML structures representing a method's call stack. The SOAP message body contains an XML representation of a method call, including the method name and its parameters[1][3][10].
  2. WSDL Definition:

    • In the WSDL file, the message part defines name and type attributes. The soap:body element specifies the use and namespace attributes[15].
  3. Use Case:

    • RPC style is typically used when the consumer views the web service as a single logical application or component with encapsulated data. It is suitable for synchronous service-to-service communication, such as payment services or stock quote services[2][6].
  4. Advantages:

    • Easier to understand and implement for simple operations.
    • Direct mapping to method calls makes it intuitive for developers[10][15].
  5. Disadvantages:

    • Does not support richer data types as effectively as document style.
    • Tightly coupled with the method signature, making it less flexible for complex data structures[10][15].

Document Style Web Services

  1. Message Structure:

    • Document style web services indicate that the SOAP body contains an XML document which can be validated against a pre-defined XML schema. The entire message is treated as a document, and the structure is defined by the XML schema[1][3][10].
  2. WSDL Definition:

    • In the WSDL file, the message part defines name and element attributes. The soap:body element specifies the use attribute only, without the namespace[15].
  3. Use Case:

    • Document style is used when the consumer views the web service as a longer-running business process where the request document represents a complete unit of information. It is more commonly found in asynchronous communication architectures, such as credit application requests or bid responses from lending institutions[2][10].
  4. Advantages:

    • Supports complex data types and richer data structures.
    • More flexible and loosely coupled, making it suitable for complex business processes[10][15].
  5. Disadvantages:

    • More complex to implement and understand due to the need for XML schema definitions.
    • Requires additional classes and tools to handle the XML documents and validate them against the schema[1][10].

Choosing Between RPC and Document Style

The choice between RPC and Document style web services depends on the specific requirements of the application:

  • **Use...
middle

middle

Gợi ý câu hỏi phỏng vấn

middle

How would you choose between SOAP and REST web services?

junior

What is cached response?

middle

What are the best practices to design a resource representation?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào