开发者

clarification on the concept of "web service"

Im a little confused on the varying definitions and implementations of web services available as implementations. Need some clarification please.

Ones I have used till now:

  1. If a vendor gives me a specific format of XML that I can send populated with data to request and I make a simple HTTP POST over the internet passing in the XML String as the payload, is this a web service call ? If so, is there a specific name to it, this kind of web service ? Because obviously, it does not use anything like Axis, WSDL or SOAP to establish this connection.

  2. A variant of this is If the vendor gives me an XSD, I use JAXB to make a java class out of it and pass in the serialized version of the object, which eventually works out to be the same as option 1.

  3. RESTful web service: Vendor gives me a URL like http://restfulservice/products and I can make HTTP Requests to the URL and depending on what HTTP verb I use, the appropropriate action is called and the response sent over the wire.

Ones I have only read about\ have a vague idea about

  1. SOAP. How does this work?.. Ive read the W3Schools tutorial and I undertsand that there is a very specific form of XML that is standardized according to W3C standards that we use to pass the same kind of messages as we did in option 1. But how does this work in real life? Vendor sends me what? Do I generate classes? Do I serialize some objects and http post them over to an address? Or do the generated objects themselves have connection methods that will do them for me?

  2. What about WSDL? When does a vendor send me WSDL and what do I do with it ? I guess I can generate classes from it. If yes, then what do I do with the generated classes ?

  3. When do I need that axis jar to generate classes from something that the vendor sends ?

As you can see, I have some clear and other mostly vague ideas about the different kinds of web services available. wo开发者_StackOverflow中文版uld help if someone ould clarify and\or point to more real-world resources. I've looked a little bit into Java Web Services on the internet and the numerous four letter acronyms that get thrown at me make me dizzy.

Thanks


If a vendor gives me a specific format of XML that I can send populated with data to request and I make a simple HTTP POST over the internet passing in the XML String as the payload, is this a web service call ? If so, is there a specific name to it, this kind of web service ?

This is still a web service, yes. It doesn't have an "official" name, I usually refer to it as XML-over-HTTP, mainly because I can't think of a better name.

SOAP. How does this work?.. Ive read the W3Schools tutorial and I undertsand that there is a very specific form of XML that is standardized according to W3C standards that we use to pass the same kind of messages as we did in option 1

SOAP provides a standard wrapper layer around the sort of messages you were sending in (1). This wrapper provides information such as an indication as to which operation you are invoking. It can also provide security services, transaction information, and so on. It's a pretty thin layer, usually.

What about WSDL? When does a vendor send me WSDL and what do I do with it ? I guess I can generate classes from it. If yes, then what do I do with the generated classes ?

Again, WSDL is a pretty thin layer, this time around an XML Schema. It defines the operations that SOAP messages will invoke at runtime, as well as the Schema types of the requests and responses. Its a way of formalising the XML document exchange interface.

Say, for example, you had an XML Schema, and have a web service as you described

  • Using JAXB to generate java source from the schema
  • Send XML documents conforming to that schema over HTTP to the web service

With WSDL and SOAP, you would extend this a bit :

  • Write a thin WSDL wrapper around the XML Schema, formalising which operations are available.
  • Use a WSDL import tool to generate client/server stubs for that WSDL/Schema. In Java, this often incorporates JAXB.
  • Use a SOAP client/server to invoke the web service

As you can see, it's essentially the same process. The difference is that SOAP/WSDL provides additional information and context to the tools, allowing those tools to do more of the work for you. It's not hugely different, though.


If you get a WSDL document from somewhere, all you really need to know is that it defines a service interface. You run it through your favourite language's binding generator to make some code that you can use to call the service. Typically that means you'll be talking over the wire to the service using SOAP messages over HTTP. SOAP's just a wrapper round sending pretty arbitrary XML messages.

Axis is a library for doing this stuff in Java (both client and server side). I suspect that there are better implementations in other libraries.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜