Not having done any modern java in a while I am a bit overwhelmed by the plethora of acronyms around providing a soap service. Can you help me summarize what the following technologies are and how they relate to each other. Some of them are obvious but I am adding them to complete the picture:
XML
SOAP
HTTP/TCP (think transports)
XSD
WSDL
JAXB
JAX-WS, JAX-RS, etc.
CFX
Let me know if I've missed something important from the list that I need to add.
XML should be one of the obvious ones
SOAP is a protocol for creating remote procedure calls (web services)
HTTP/TCP transport protocols
XSD XML Schema Definition, defines the data types of your XML documents, useful for Schema validation and parsing to Java objects
WSDL web service definition language, a descriptor for SOAP based web services. Contains the operations you can call and the data (using XSD) to use. The WSDL puts it all together.
JAXB API for binding XML and Java types, so you can parse XML files to Java objects and vice versa
JAX-WS API for SOAP based web services
JAX-RS API for RESTful web services (alternative to SOAP)
CFX is a framework from Apache for web services. All other technologies above are just APIs / standards, CFX is an implementation of these.
XML
markup language favoured by SOAP webservices. You should be considering whether JSON meets your needs
SOAP
Used to mean Simplified Object Appliction Protocol, but really now means 'non-RESTful' web services
HTTP/TCP (think transports)
Webservices tend to use HTTP, but don't have to. Benefit of HTTP is ubiquity / firewall punching (via proxies)
XSD
XML schema Definition - a 'better' validation framework for XML than DOCTYPE. This is arguable. XSD is overly heavyweight for many applications
WSDL
Web Service Description Language - defines the methods/parameters of SOAP based webservices. Arguably too heavyweight for many applications
JAXB
Java XML Binding - allows XML <-> Java object <-> XML roundtripping. Can be difficult to work with for non-trivial examples
JAX-WS, JAX-RS, etc.
JAX-WS is the (large) family of webservice standards around SOAP
JAX-RS is the API for RESTful webservices.
CFX
???
REST
An alternative to SOAP webservices based on Roy Fieldings paper. Often considered simpler than SOAP and easier to use. But care is needed to implement correctly, Noteably HATEOAS (Hypertext As The Engine Of Application State) is often misunderstood.
JSON
Javascript Object Notation - an alternative data representation to XML based on Javascript data literals
Related
We have currently implemented SOAP endpoints with CXF (Spring Boot). In accordance with the contract-first approach, we provide a WSDL, generate Java objects, and services from it (cxf-codegen-plugin) and finally implement the service interface.
This is all very nice and simple, but we only need the SOAP XML or the corresponding DOM tree. Not only is the conversion to Java objects unnecessary, we also have to convert them back to XML and lose some information from the original XML.
As far as I understand is SAAJ (SOAP with Attachments API for Java) exactly right here, or am I missing something? At most all resources about SAAJ are quite old and "low level". I cannot find good resources for that kind of approach.
In addition, we want to implement new services as microservices soon and are currently reviewing Quarkus and Apache Camel. However, I cannot find a (simple) way to create corresponding endpoints from the WSDLs, via which we then receive the SOAP message as plain XML / DOM tree.
In jax-ws, message-level access can be accomplished on the server side using web service Provider-based endpoints, and on the client side using Dispatch clients.
A web service Provider-based endpoint offers a dynamic alternative to the Java service endpoint interface (SEI)-based endpoint. Unlike the SEI-based endpoint that abstracts the details of converting between Java objects and their XML representation, the Provider interface enables you to access the content directly at the XML message level—without the JAXB binding. web service Provider-based endpoints can be implemented synchronously or asynchronously using the javax.xml.ws.Provider or com.sun.xml.ws.api.server.AsyncProvider interfaces, respectively.
See https://cxf.apache.org/docs/provider-services.html for details
I am learning web services in Java. I would like to know the uses for the following 4 classes with the help of a very simple use case - WebServiceFeature, AddressingFeature, MTOMFeature, RespectBindingFeature.
Suppose, I am publishing a web service which will list all States in the United States. How would I utilize these 4 classes?
Java API for XML-Based Web Services (JAX-WS) Version 2.1 introduced the concept of features as a way to programmatically control specific functions and behaviors.
WebServiceFeature as per Java Doc
A WebServiceFeature is used to represent a feature that can be enabled or disabled for a web service.
The JAX-WS specification will define some standard features and JAX-WS implementors are free to define additional features if necessary. Vendor specific features may not be portable so caution should be used when using them.
AddressingFeature as per Java Doc
AddressingFeature represents the use of WS-Addressing with either the SOAP 1.1/HTTP or SOAP 1.2/HTTP binding. Using this feature with any other binding is undefined.
This feature can be used during the creation of SEI proxy, and Dispatch instances on the client side and Endpoint instances on the server side. This feature cannot be used for Service instance creation on the client side.
MTOMFeature as per Java Doc
This feature represents the use of MTOM with a web service.
Also
JAX-WS supports the use of SOAP Message Transmission Optimized Mechanism (MTOM) for sending binary attachment data. By enabling MTOM, you can send and receive binary data optimally without incurring the cost of data encoding needed to embed the binary data in an XML document.
RespectBindingFeature as per Java Doc
This feature clarifies the use of the wsdl:binding in a JAX-WS runtime. This feature can be used during the creation of SEI proxy, and Dispatch instances on the client side and Endpoint instances on the server side. This feature cannot be used for Service instance creation on the client side.
This feature is only useful with web services that have an associated WSDL.
Use Cases - unfortunately, see the Java Docs - I only say unfortunately as with me developing web services for several years now - I've never needed to use "WebServiceFeature,AddressingFeature, MTOMFeature, RespectBindingFeature" - they're for niche use cases which I dont believe most developers need to deal with. The most beneficial one I see would be the MTOMFeature but if you simply want a web service that lists all of the United States - you wouldn't likely need anything that elaborate.
Some Use Case Findings
MTOM: Using JAX-WS, you can send binary attachments such as images or files along with web services requests. With your example of States - you could have a web service that request that sets/updates each a picture of the states state bird and a base64 encoded audio file of the state song - the picture and song could be MTOM attachments.
AddressingFeature: This looks like it's just used when either the web service or web service client need to use WS-Addressing. I'd imagine trying to integrate with a third party web service that requires the use of WS-Addressing in which case your client you write would need to specify it's use
RespectBindingFeature: You can use the RespectBindingFeature to control whether a JAX-WS implementation is required to respect the contents of a Web Services Description Language (WSDL) binding that is associated with an endpoint. By implementing the feature, RespectBindingFeature, you have specified to enforce adherence of the contents of a WSDL binding that is associated with an endpoint for your JAX-WS application. The actual enforcement of the use of the WSDL document specifications, when they are provided, at run time has not been well defined in versions of the JAX-WS specification previous to Version 2.1.
WebServiceFeature: this is the parent class for the other features. The use case I imagine would only be the facts that the sub-classes inherit from it.
I've some confusions about ReST clients and need a bit of help.
For ReST, does the service provider give WSDL document or not? If not, how does the client will know what kind of JSON data to expect? When I invoke the rest client, I will recieve the JSON/XML response in a string format which I'll need to convert it into a Java object(or Javascript, if using on client side) to do any meaningful tasks with the response. So it seems like I, as a client developer, need to know the WSDL or the Schema definition so that I can build a java object similar to the JSON response I'm expecting. But if you go by this answer, generating a client class based on the service definition flies directly in the face of ReST fullness. If that is the case, how do I go about creating my client code?
WADL/Web Application Description Language is not a standard but is gaining popularity for REST APIs contract definition.
The Web Application Description Language (WADL) is a machine-readable
XML description of HTTP-based web applications (typically REST web
services).1 WADL models the resources provided by a service and the
relationships between them.1 WADL is intended to simplify the reuse
of web services that are based on the existing HTTP architecture of
the Web.1[2] It is platform and language independent and aims to
promote reuse of applications beyond the basic use in a web
browser.
For documentation:
https://github.com/wordnik/swagger-core/tree/master/modules/swagger-jaxrs
For client code:
https://github.com/wordnik/swagger-ui
You integrate the library and annotate your resources and online documentation is generated on the fly.
You also need a client for which you can integrate the ui.
The dynamically generated REST client looks something like this:
http://petstore.swagger.wordnik.com/
I'm a newbie to webservice, and I've read this chapter (and some other articles) to get an idea about SOAP. Sad, I couldn't find the next chapter about WSDL in java.net.
Anyway, let's suppose I need to implement SOAP 1.1/HTTP 1.1.
The used "contract" to exchange information is WSDL.
So, in order to create webservices provider :
What would be the role of JAX-WS?
Would it be needed or is it an alternative to WSDL?
If needed, shall we combine it with ( SOAP/HTTP + WSDL)?
What would be the role of JAX-WS in this combination?
Could it be replaced by JAX-RPC (or by something else)?
Is JAX-WS cross-platform or only specific to Java?
If moving to another platform, such as C or C++ or Python, would we be able to use JAX-WS if needed to be combined?
Talking C#,.Net... Is JAX-WS similar to WCF?
Thank in advance :)
SOAP and HTTP are message protocols. JAX-WS is the implementation in java for generating these messages. It handles all the low level details of converting java objects to SOAP messages, generating java classes based on WSDL and XSDs. JAX-WS is used for creating SOAP based as well as Rest based messages. It is the underlying technology that handles the messages on both client and server side. JAX-WS implementation is based on WSDL and SOAP standards. It is java specific.
I am not aware of what WCF is.
SOAP 1.1/HTTP 1.1.
SOAP(XML based Message protocol) over HTTP(Transport Protocol)
The used "contract" to exchange information is WSDL
Everyone wants to define their own way and framework to describe their webservice. So Microsoft has created contracts for WCF framework.The content of the WSDL document defines the contract of the web service for ex. service, data, fault, message contracts. RIP developers.
What would be the role of JAX-WS?
JAVA API for XML based web services. Use to create soap based webservice provider. It uses annotations.
Would it be needed or is it an alternative to WSDL?
JAX-ws is a framework or API.It is an alternative to WCF, you can say not WSDL. WSDL is a document which describes your webservice in XML format.
If needed, shall we combine it with ( SOAP/HTTP + WSDL)?
What would be the role of JAX-WS in this combination?
JAX-WS can implement SOAP/HTTP based webservice. USing JAX WS, you can generate WSDL which will describe your defined service implementation.
Could it be replaced by JAX-RPC (or by something else)?
yes, JAW-RS would also work.
Is JAX-WS cross-platform or only specific to Java?
JAX_WS is only specific to java. But you can design/implement webservice using JAX-ws which would be cross-platform.
If moving to another platform, such as C or C++ or Python, would we be able to use JAX-WS if needed to be combined?
You can use jax ws implemented webservice provider to interact with any other language based webservice client.
Talking C#,.Net... Is JAX-WS similar to WCF?
JAX-WS, WCF both are framewrok to implement webservice in java, .net respectively.
Note: You are quite confused between language, framework, protocol, implementation methods etc. Your questions are very ambiguous. Keep Learning.
Can we generate an xml file using webservices in Java, and if so how?
Generating XML files has nothing to do with webservices. The common SOAP based webservices communicate with messages written in XML. So to call a webservice, you'll have to create a XML document that implements some xml schema and send the xml document to the servers address. And you won't need files, usually the XML documents are created in memory and not written to files.
Apache Axis2 is a quite powerful library that takes care of most of the marshalling/unmarshalling and communication stuff.
There are two Java Web Service Standards:
Java API for XML Web Services (JAX-WS)
Java API for RESTful Web Services (JAX-RS)
Each spec has multiple implementations. GlassFish is the reference implementation for both these standards.
You can either interact directly with XML, or with POJOs that are converted to XML via an XML binding layer. The standard binding layer for JAX-WS and JAX-RS is Java Architecture for XML binding (JAXB).
For an example of a JAX-RS Webservice check out:
http://bdoughan.blogspot.com/2010/08/creating-restful-web-service-part-15.html
Create a web service (e.g. using Java 6 annotations) and let the annotated method return a DOM tree transformed to a string.