Difference between RPC Style and Document Style SOAP web Services in Java?

Connect with

java-logo
In Java web services specially JAX-WS standard, RPC and Document are two different approach of creating JAX-WS style of web service. RPC is older one and Document is newer one. RPC style generate WSDL document based on the method name and it’s parameters. No type definitions are present in WSDL document.
Document style contains type and can be validated against 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.

1. Java Service Implementation class

We should promotes interface instead of directly implementation class but for simplicity I’m creating service impl directly which is 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());
	}
}

2. RPC xml using SOAPBinding.Style.RPC

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


































3. Document xml using SOAPBinding.Style.DOCUMENT

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






































4. 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




















5. References:

Suggestions are welcome to improve this post.


Connect with

4 thoughts on “Difference between RPC Style and Document Style SOAP web Services in Java?

  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 Reply

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