I have to write a REST client to consume a service written in .Net. The problem is that the .Net service returns a gzip compressed serialized DataSet. How do I parse it? I have seen other solutions explaining how to do it using SOAP (I have to use REST). Another solution says to write a .Net proxy. But my deployment server is a linux machine with limited access so I may not have the luxury of using tools like Mono.
The folks exposing service haven't provided any wsdl specs. Just given ways to construct URLs that when invoked will return what I need. So what's my way forward :
Try SOAP? Is that even possible? I have no wsdl info. So I assumed it will be REST.
Create a .Net proxy that consumes this service and converts to more readable xml, and find ways to make this .Net exe run on linux?
Continue searching for a solution/library that can read DataSet? I have been developing clients using Spring RestTemplate which doesn't seem to work here.
Also, accessing the URL from Advanced Rest client shows that Content-Type: compressed/DataSet
So I had to end up creating a .Net proxy that decompresses and deserializes the DataSet response, convert to xml and save at a shared location from where Java program can pick up.
Related
I'm used to integrating with SOAP Webservices where the wsdl is accessible and can be used to generate a java client using wsimport. I've recently been given a RESTful end point which uses XML as the payload type. So far as I can see there is no WADL\ Swagger YML file I can access to get a definition of the service.
All I know so far is:
1. The endpoint
2. It operates behind HTTP basic auth
3. It accepts a POST
4. The 3 test XML payloads I have all seem to "work" returning an XML response relating to what I am trying to do
5. The URI does not change depending on the the action I am perform, the service reacts differently based on varying XML input (the request contains a payload-id attribute which seems to indicate the type of operation being performed)
From the above the service doesn't seem very "REST-like" it could just be a process listening on port for a specific request and doing crude string manipulations to parse values and then use string concatenations to crudely build a response. I get that for the most part REST is just that at a low level but I am hoping to somehow manage the apparent crudeness of the service a bit better.
How I can generate a "clean" Java client for this service (something akin to what can be done with wsimport) given that I have the XML sample requests for the 3 different operations that appear to be exposed?
For the above I was thinking that I'd somehow need to create the WADL\ Swagger YML myself, or perhaps there is a tool which could use the requests I have to build these definitions dynamically?
We eventually went for using the Feign which is a Java to HTTP client binder. It's Netflix OSS but seems to be an older library (osslifecycle=archived).
Wrapping the HTTP service was extremely easy as it only has one URI which we POST an XML payload to. We received XSD's from the service owner which we have converted into JAXB object which are then marshaled and un-marshaled within the Feign call. Feign has a concept of encoders and decoders which you can use to write your own mappers or use a provided mapper (JAXBEncoder\ JAXBDecoder).
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 have wrote a java class which accepts some input and gives some output.
I have another web application, which would like to send a request json containing the input data to a server and receive response json containing the output data. The server will receive the request, parse it and format the input for the java class, and then utilize the java class to calculate the output, and finally format the response and send the response to the web application.
However, I am stuck at how to write this server.
Currently I have some ideas in mind:
1) Using a big frame work such as Play or Spring -> but usually those requires tomcat to deploy, which is too heavy for my little java class
2) Write my own HTTP server with java, according to this guide http://oreilly.com/catalog/javanp2/chapter/ch11.html
Anyone knows that if there is a light weighted java framework or java library that I can use for my purpose? By utilize which, I can simply write my server and run my service, but do not need to handle too much networking and threading?
Thanks for helping me out! All answer appreciated!
Jetty is an example of a server that can be run embedded. This removes needing to build a .war and deploy it to a servlet container such as Tomcat. Here are some examples.
I am doing a project using Java and BPEL. I successfully created webservices in Java and integrated them using BPEL. All i generated a single output WSDL file. Now, I have to use this output WSDL file in my application using SOAP communication. How can i do that? Is there any help out side for such scenarios? Walkthroughs are really appreciated..
Depending on the architecture of your application (Standard Java, Spring-based, ...) there might or not be a documented procedure to consume a SOAP-based webservice.
On the other hand, you're always free to pick a webservice development framework to handle that. For instance, you could pick either CXF or AXIS2 (I believe these are the two most popular frameworks for Java WebServices). Each of these frameworks provides a tool called "wsdl2java" that helps you generate client-side/server-side/both Java classes. Then, you can easily add those classes and the requireds libraries to your application.
Having used CXF in the past, It even does provide several way to consume a webservice
Generating the client-side classes
Using CXF dynamic client factory : basically, you'll retrieve an endpoint proxy from a factory object.
Hope that'll help
I start with SoapUI (or downloadable from sourceforge), that will let you consume the WSDL and fire off requests against your server. Typically I'm hitting someone else's webservice, and trying to figure out what the data looks like before I start wiring my code together, but in your case its just a verification that the services would be/are working.
Then, as #KHY said, you can automatically convert the wsdl into java with a wsdl2java and start coding (look under the Related list on the right panel of this SO screen)
If it is a Java application, then the easiest way to consume a service is using JAX-WS. It's really easy to create a Web service client from WSDL.
See this link
Once you deploy the BPEL project on server, then refer the WSDL with http://server:port/application/YourBPELProjectService?WSDL in the consuming application. You will need to write different client code based on the BPEL type - Synchronous, Asynchronous etc.
I’m new to the concept of web services and I’m currently working on a project where I need to retrieve some data from an external application via SOAP.
This application provides an RPC encoded WSDL. I’m currently finding it very difficult to create a client for this service in Java due to RPC being superseded.
The closest I’ve got so far is using JAX-RPC but every time I try to run the ws-compile programme I get an error which states “error code to large”.
I have researched on AXIS 2, and tried to compile it’s WSDL2JAVA but due to RPC encoding I keep getting exception on all the data binding methods.
I was wondering if I can have some advice or a guide on generating Java Clients from RPC encoded WSDLs. What are the steps? What should I consider before I even try to write the client?
I’m currently using netbeans 6.9.1
If you are trying to generate the client stub from the wsdl url, then follow this
Thank you