0

i have worked on some projects under experience people and i saw them calling a web service by writing code in java that makes HTTP connection and send data using SOAP envelop in XML format. I have been using same thing for long time. Now i watched a tutorial on youtube where the trainer used wsimport command to generate java classes from wsdl url and copied that classes in project, initialized object of service and called appropriate method for communicating with web service. Now i got confused, means i think using java classes for accessing web service is much easy than soap envelop. so i searched on google but did not get any proper answer. Please explain it which way is better and why?

Lalit Chattar
  • 1,914
  • 8
  • 27
  • 49
  • possible duplicate of [How to do a SOAP Web Service call from Java class?](http://stackoverflow.com/questions/15940234/how-to-do-a-soap-web-service-call-from-java-class) – Adam Aug 27 '14 at 18:33

1 Answers1

2

The wsimport tool generates JAX-WS portable artifacts, such as:

  1. Service Endpoint Interface (SEI)

  2. Service

  3. Exception class mapped from wsdl:fault (if any)

  4. Async Reponse Bean derived from response wsdl:message (if any)

  5. JAXB generated value types (mapped java classes from schema types)

So, this tool generate almost everything for you, make our lives easier.

If we had to generate it ourselves, we would have to:

*Serializes the object to XML

*Calls the web method through HTTP manipulation

*Parse the returning XML response back into an object

Bruno Franco
  • 2,028
  • 11
  • 20