1

I'm searching for a way to consume soap webservices without using wsimport and tools like that. So far, everyting I found requires the wsdl artifacts generation and I want to avoid it because I don't know wich webservices will be used.

The idea is to give the user the possibility to add several WSDL's urls / methods and the program consume them and send it's response to another url.

I'm not looking for out of the box solutions/code or something like that. What I need is to know if it is possible or not and how to aproach this problem, ideas and things like that.

Thanks!

Zacenas
  • 13
  • 3
  • There's nothing magic about SOAP, it's just XML sent over some communication protocol (typically HTTP). Technically you don't _need_ anything more than TCP sockets. – gustafc May 26 '15 at 13:11

1 Answers1

0

SOAP mandates a contract between the Client and Server. The contract is that Client will give a request XML is XYZ format and Server will give response in ABC format. Without this, SOAP does not work. This is what is defined in WSDL. So we have to use WSDL.

Tools like wsimport, wsdl4j convert these WSDL files into an object hierarchy and prepares a JAXB wrapper for you, to make life easy!

Now if you do not want to use the tools which automatically convert WSDL to Java Beans or anything of that sort, note SOAP is based on nothing but an XML. If you know how to parse an XML in java, thats pretty much it. You can use a JAX Parser to achieve this and you can read everything that comes in a SOAP request and response.

The problem that you will face is, as the complexity of the SOAP XML grows, it will be difficult for you to parse the XML properly, identify the nodes, values and relations properly. And add to that the problem where in you cannot, without a proper object hierarchy , relate between nodes which are distance apart. Meaning, from line 100 you cannot go back and relate a line 10 node, unless you start maintaining your own objects, relations etc. (which is not what you want, i guess)

Using Java Beans the object hierarchy is maintained and because of that it is easy for you to relate them between different objects at different nodes easily. But JAXB is comparatively slower than JAX.

aksappy
  • 3,400
  • 3
  • 23
  • 49
  • Using wsimport on runtime and importing the generated classes would by messy as parsing the whole XML like you said no? The problem is I don't know what WSDl's will be used so I can't parse them up front. So manual parsing and hoping for not having many complex objects is the solution? Thanks for your time! – Zacenas May 26 '15 at 14:39
  • It will be because u need to get the wsdl for every soap call. Web Services if has to be dynamic, REST is a better way forward. – aksappy May 26 '15 at 15:13
  • REST with json was my first choice. Problem is the client doesn't support it. Only SOAP WSDL. Thanks for your time again! – Zacenas May 26 '15 at 15:40
  • Why don't you use a schema validator to check which WSDL it is during runtime and then based on that have separate parsing mechanisms. Just a thought. And, no prob mate, pleasure is all mine – aksappy May 26 '15 at 15:49