There are many differences between RPC and Document web services. The important differences between RPC and Document are given below:

RPC Style

1) RPC style web services use method name and parameters to generate XML structure.

2) The generated WSDL is difficult to be validated against schema.

3) In RPC style, SOAP message is sent as many elements.

4) RPC style message is tightly coupled.

5) In RPC style, SOAP message keeps the operation name.

6) In RPC style, parameters are sent as discrete values.

Let's see the RPC style generated WSDL file.

WSDL file:

In WSDL file, it doesn't specify the types details.

  1. <types/>  

For message part, it defines name and type attributes.

  1. <message name="getHelloWorldAsString">  
  2. <part name="arg0" type="xsd:string"/>  
  3. </message>  
  4. <message name="getHelloWorldAsStringResponse">  
  5. <part name="return" type="xsd:string"/>  
  6. </message>  

For soap:body, it defines use and namespace attributes.

  1. <binding name="HelloWorldImplPortBinding" type="tns:HelloWorld">  
  2. <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>  
  3. <operation name="getHelloWorldAsString">  
  4. <soap:operation soapAction=""/>  
  5. <input>  
  6. <soap:body use="literal" namespace="http://javatpoint.com/"/>  
  7. </input>  
  8. <output>  
  9. <soap:body use="literal" namespace="http://javatpoint.com/"/>  
  10. </output>  
  11. </operation>  
  12. </binding>  

Document Style

1) Document style web services can be validated against predefined schema.

2) In document style, SOAP message is sent as a single document.

3) Document style message is loosely coupled.

4) In Document style, SOAP message loses the operation name.

5) In Document style, parameters are sent in XML format.

Let's see the Document style generated WSDL file.

WSDL file:

In WSDL file, it specifies types details having namespace and schemaLocation.

  1. <types>  
  2. <xsd:schema>  
  3. <xsd:import namespace="http://javatpoint.com/" schemaLocation="http://localhost:7779/ws/hello?xsd=1"/>  
  4. </xsd:schema>  
  5. </types>  

For message part, it defines name and element attributes.

  1. <message name="getHelloWorldAsString">  
  2. <part name="parameters" element="tns:getHelloWorldAsString"/>  
  3. </message>  
  4. <message name="getHelloWorldAsStringResponse">  
  5. <part name="parameters" element="tns:getHelloWorldAsStringResponse"/>  
  6. </message>  

For soap:body, it defines use attribute only not namespace.

  1. <binding name="HelloWorldImplPortBinding" type="tns:HelloWorld">  
  2. <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>  
  3. <operation name="getHelloWorldAsString">  
  4. <soap:operation soapAction=""/>  
  5. <input>  
  6. <soap:body use="literal"/>  
  7. </input>  
  8. <output>  
  9. <soap:body use="literal"/>  
  10. </output>  
  11. </operation>  
  12. </binding>