0

I've never used SOAP or EJB. I read about SOAP and can't grasp one (maybe the main) point.

Question: Why should one use remote interfaces instead of simple request/responce scheme?

My considerations: SOAP allows us to invoke methods of remote services. It uses XML. But why it's better than just use SOA (service oriented approach) and send an JSON request -> get JSON response. I do so in my application with help of WebSockets and JSON. Moreover, SOAP is slow, seems it is slower than approach that I need.

VB_
  • 45,112
  • 42
  • 145
  • 293

2 Answers2

1

I suppose the advantage of the remote interface is that you wouldn't have to parse any XML. When you receive your reply from a remote interface an object is constructed that you are able to use without any further processing. However SOAP seems to be a more popular method currently as you are not restricted to a particular environment. For instance you have to use java on the client to use the remote interface but with SOAP any client can accept and process the XML

onesixtyfourth
  • 744
  • 9
  • 30
1

The reason for this is SOAP takes a contract-first approach. This also allows us to build classes from these contracts so we have classes that can be built by a WSDL. This is very useful because it means we don't have to build classes representing the web service endpoint, however, if the endpoints signature changes we need to update our associated generated WSDL classes.

SOAP, in my humble opinion, is much more useful for say .NET or Java because of the classes that can be generated from it and the help your IDE can bring by instantly allowing you to access these classes. When I've used php, I always found it felt like SOAP wasn't quite as easy to work with as REST because of having to build up XML responses when all you want to actually send is "something=true".

David
  • 19,577
  • 28
  • 108
  • 128
  • in my case I can build classes with help of jackson. I mean I get json string, invoke `mapper.objectToJson` and get the object. What is the advantage? – VB_ Mar 07 '14 at 15:11
  • But besides SOAP there are also another choices. JSON? – VB_ Mar 07 '14 at 15:13
  • JSON itself isn't an alternative to SOAP, I think you mean REST vs SOAP as JSON is just an object specification, SOAP is a web service protocol. – David Mar 07 '14 at 15:14
  • I write my service. It use websockets and json. No mean of SOAP, no mean of REST. And I've never regret about it. Can you provide me a situation when I must use SOAP, and websockets and JSON are bad? – VB_ Mar 07 '14 at 15:16
  • objectToJson just converts an object to a JSON object, it doesn't actually do the transfer, call the endpoint, do the HTTP handshake etc that SOAP does. – David Mar 07 '14 at 15:16
  • It's just about how you want to deliver them and expect them to be consumed, the first answer here about the WSDL describing exactly what you're meant to provide to the service http://stackoverflow.com/questions/20101374/soap-vs-rest-when-to-use-one-and-not-the-other – David Mar 07 '14 at 15:18
  • so the question is how Do I like to send/receive objects? I mean I can achieve all SOAP can with standard scheme – VB_ Mar 07 '14 at 15:31