Difference between RPC Style and Document Style SOAP web Services

Connect with

Difference between RPC Style and Document Style SOAP web ServicesLearn difference between RPC Style and Document style SOAP web Services in Java. RPC style vs document style, its similarities and differences in SOAP web services.

1. Overview of RPC style and Document Style

In Java web services specially JAX-WS standard, RPC style and Document style are two different approaches to creating a JAX-WS style of web service. RPC is an older one and the Document is the newer one. RPC style generates WSDL document based on the method name and its parameters. No type definitions are present in the WSDL document.
Document style contains the type and can be validated against the predefined schema. Let’s look at these with a simple program. Below is a simple test program where I am using Endpoint to publish my simple SOAP web service.

2. Java Service Implementation class

We should promote interface instead of directly implementation class but for simplicity, I’m creating service impl directly for RPC style of web services, for instance, TestService.java.

TestService.java

package com.mysoftkey.jaxws.service;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.ws.Endpoint;

@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class TestService {

	@WebMethod
	public String sayHello(String msg){
		return "Hello "+msg;
	}
	
	public static void main(String[] args){
		Endpoint.publish("http://localhost:8888/testWS", new TestService());
	}
}

3. RPC Style xml using SOAPBinding.Style.RPC

When I run above program and access the WSDL, it gives following WSDL XML file
rpc.xml


































4. Document style xml using SOAPBinding.Style.DOCUMENT

In this section you learn about Document style of SOAP web services. Here, types element is empty and we can’t validate it against any schema. Now just change the SOAPBinding.Style.RPC to SOAPBinding.Style.DOCUMENT and you will get below WSDL.
document.xml






































5. SchemaLocation URI

when you Open schemaLocation URL in browser and you will get below XML which I share for references. Here, WSDL document can be validated against the schema definition.

schemaLocation.xml




















6. References:

I hope you enjoyed this post about differences between RPC style and Document style of SOAP web services.
Suggestions are welcome to improve this post.
You can visit JAX-WS Java web service tutorial for more details.
Happy Learning! 🙂


Connect with

4 thoughts on “Difference between RPC Style and Document Style SOAP web Services”

  1. Pingback: joe

  2. Generally I do not read article on blogs, but I wish to say that this write-up very compelled me to take a look at and do it!
    Your writing taste has been surprised me. Thank you, very nice article.

  3. Hi! I just wanted to ask if you ever have any issues with hackers?

    My last blog (wordpress) was hacked and I ended up
    losing months of hard work due to no back up. Do you have any solutions
    to protect against hackers?

Leave a Comment

Your email address will not be published. Required fields are marked *