File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Need some explanations about web-services basics. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Need some explanations about web-services basics." Watch "Need some explanations about web-services basics." New topic
Author

Need some explanations about web-services basics.

Dmitry Zhuravlev
Ranch Hand

Joined: Apr 14, 2010
Posts: 91
Gentlemen, please clarify some points in web-services basics. Am I right?

As far as I understand:

1) web-service is some application that accepts HTTP GET or POST requests. In fact, each servlet is a production-ready web-service.

2) the only thing we need to interact with the web-service is a code that sends HTTP requests. Actually we can write web-service client without AXIS or JAX libraries.

3) the purpose of AXIS and JAX libraries is to make it possible for a programmer to interact with Java classes and methods, and not XML strings in his application.

4) ok, but anyway, if I dont want to use any web-service frameworks, or may be I just want to make a quick and dirty test of a web-service and my credentioals, for example, how can I create a correct HTTP POST or GET request basing on WSDL file? Whats exactly should I do? Copy some part of WSDL to request header or data and send it, or make some modifications to WSDL XML?

5) could you please clarify main differences between AXIS and JAX? which one is preferrable? Does it depend on WSDL provided or not?
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

Hi Dmirty,

I'd like to be as brief as possible to try to answer your questions.

1. Yes, but web service is more than that. Restful web services use HTTP PUT and DELETE methods as well.

2. Not necessarily HTTP requests. You can also use JMS/MQ/SMTP etc. as transport protocols. Having said that majority of web services use HTTP as transport. You need web service API to create client. If you are referring JDK 6, then it has got JAX-WS API.

3. Right to some extent. Unless you have some data binding API like XMLBeans, JAXB, etc. used along with web services API, XML strings can't be unmarshalled to Java objects and vice-versa.

4.
Copy some part of WSDL to request header or data and send it, or make some modifications to WSDL XML?

I don't quite understand what you mean here. WSDL is used to generate test client(using some web service API, so you have to use web service framework) if you want to create test web service.

5. All web service frameworks(REST excluded) require WSDL. You can get many articles on various web services comparisons, if you search in your favourite search engine. It's a huge topic in itself to explain in few lines.


Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41600
    
  55
Dmitry Zhuravlev wrote:1) web-service is some application that accepts HTTP GET or POST requests. In fact, each servlet is a production-ready web-service.

I really wouldn't call all servlets web services - those are generally based on SOAP or REST, and that's not true for servlets in general.

5) could you please clarify main differences between AXIS and JAX? which one is preferrable? Does it depend on WSDL provided or not?

By "JAX", I assume you mean JAX-WS, or rather, its reference implementation that forms the core of the Metro project. Note that JAX-WS (and JAX-RS) are APIs, while Axis and Metro are implementations; both support JAX-WS and WSDL (and some other features like SAAJ and WS-Security). Both are popular, both are capable, so there's no easy choice between the two.


Naren Chivukula wrote:2. You need web service API to create client.

No, especially for RESTful services using just the HttpUrlConnection class, or the HttpClient library, works fine.

5. All web service frameworks (REST excluded) require WSDL.

Well, all major SOAP implementations support WSDL, but that's certainly not required to implement SOAP services. Having said that, it is generally accepted practice to supply the WSDL of a service along with the service, so that it's easier to build clients.


Ping & DNS - my free Android networking tools app
Dmitry Zhuravlev
Ranch Hand

Joined: Apr 14, 2010
Posts: 91
Guys,
thank you for the explanations.

One thing remains unclear for me. I will try to explain in other words.

If the majoruty of web-services accepts HTTP POST or GET requests as input data, then why can't I create a web-service client which sends HTTP POST requests and accepts its response? It looks very simple, I would not need any frameworks for this.
Will this work?

If no - why?
If yes - in which form should I pass some parameters into my POST request? I mean how should I encode method name, method namespace, method parameters in POST body or POST header?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41600
    
  55
Sure, you can implement a web service without resorting to any framework, but why would you? The frameworks do a lot of work for you, like all the things you're asking about in the "If yes - ..." part, and then some. There's no good reason to duplicate all the work of reinventing the wheel.
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 576

Well, all major SOAP implementations support WSDL, but that's certainly not required to implement SOAP services. Having said that, it is generally accepted practice to supply the WSDL of a service along with the service, so that it's easier to build clients.

Agree with Ulf. SAAJ is one such API, which doesn't need to have WSDL to invoke web services. Having said that, the details which we require to build SAAJ message come from usually WSDL if not verbally from someone
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need some explanations about web-services basics.