I want to call a SOAP service using REST service. Can anybody please share some example programme or snippets where we can invoke a soap service using JAX-RS(Jersey) written REST service. I am using jdk 1.7 & eclipse juno. What will we be using to refer to the soap service? Please note that I am entirely new to webservice, so examples will be a huge help!
Asked
Active
Viewed 1.5k times
3
-
It looks like you're trying to mail a holiday card by just shouting someone's name, which you can't do. Likewise, you can't call a SOAP service by using a REST service. What you can do, is manually invoke the Web Service by using Java's `Dispatch` API (Google it). – Davio Sep 30 '14 at 13:06
-
I didnt know anything about this but i found an answer saying it is just a normal thing to do at this link stackoverflow.com/questions/17986498/calling-soap-in-jersey Is this answer wrong or my understandin?? – @Davio – RBz Oct 01 '14 at 05:35
-
You can do it, but they're different things. You can do whatever you like from the point where your REST service is called. You could connect to a database, create an infinite while loop, it's your party! – Davio Oct 01 '14 at 07:10
-
So you are saying your first comment is not right? i am having a hard time understanding the difference of wrapping SOAP with REST and Calling SOAP with REST. Can you please explain with an example? @ Davio – RBz Oct 01 '14 at 09:33
-
Well, you can create a Java class to respond to SOAP calls and another to respond to REST calls. I thought you were trying to write a REST client to invoke a SOAP service, which is nonsense, you must use a SOAP client for this. It's okay if you want to call a SOAP service from your own REST listener, but you must use a SOAP client, like Java's Dispatch API. – Davio Oct 01 '14 at 14:26
2 Answers
4
You cannot use a REST service framework to access a SOAP Web-Service. This are two completely different technologies.
It's like you're asking how to drive with a locomotive on a motorway...

Uwe Plonus
- 9,803
- 4
- 41
- 48
-
I didnt know anything about this but i found an answer saying it is just a normal thing to do at this link http://stackoverflow.com/questions/17986498/calling-soap-in-jersey Is this answer wrong or my understandin?? @Uwe Plonus – RBz Oct 01 '14 at 05:32
-
@RBz Perhaps you question is not clear. If you want to _wrap_ a SOAP service with a REST Service then this is possible as described in the answer mentioned. If you want to _call_ a SOAP Service using a REST service then this is simple impossible. – Uwe Plonus Oct 01 '14 at 05:35
-
Can you please define what we mean by wrapping? Please forgive my ignorence, i dont understand how both are different. @Uwe Plonus – RBz Oct 01 '14 at 05:38
-
@RBz _Wrapping_ means that you create a REST service and call a SOAP service out of the newly created REST service. _Calling_ means that you create a REST service and want to call a SOAP service with this. – Uwe Plonus Oct 01 '14 at 06:02
-
I cant say I am clear about what you are saying. Reading your answer and the comments together. Can you give an example so that i can relate? @Uwe Plonus – RBz Oct 01 '14 at 09:31
-
1@RBz to explain it with pseudo code: Using `MyService extends RESTClient` to access a SOAP service does not work (_Calling_). Using `MyService extends RESTService` and `handle() { call SOAPService }` will work as you create a new web service that is a REST service and call from this new service a SOAP web service (_Wrapping_). – Uwe Plonus Oct 01 '14 at 10:03
-
So practically its safe to say that we can invoke/use a soap service inside rest. Thats what i was trying to understand. Thanks @Uwe Plonus – RBz Oct 01 '14 at 12:41
4
You can call the SOAP service using restful API. In SOAP the xml is built dynamically. You can built the soap request XML in your program and call the SOAP URI with this xml as string parameter.

BelieveToLive
- 281
- 1
- 4
- 18