How to use WSDL file, parse SOAP message? - eclipse

This is my first post here(pardon me if I'm vague).
Actually I've got a wsdl file (which have soap requests, schema, generates pojo) and my task is to
1) Integrate that with eclipse .
2) Send the request to the server.
3) get the response back.
4) And parse the response in Java.
And I'm not at all aware of where to start. Someone suggested of using Apache axis with eclipse (I'm not aware of that too).
Thank you for your help, And also please suggest what is the best way of parsing and how to parse a SOAP message that way in JAVA.
A demo will be so much appreciated.
Thank You.... and sorry if I'm expecting too much, I'm newbie :)

Create auto generated classes from WSDL. You can use various tools that help in generate classes from WSDL file ex: JAVAtoWSDL or ApacheAxis.
Once classes has been generated then you can parse request and create response with JAXB, that is marshall and unmarshall.

Related

Regarding creation of webservice client using eclipse and CXF Apache

I have a wdsl with me and have been assigned with a task to create webservice client for that using apache CXF. I would be very grateful if someone can give me a step to step insight right from setting up the applications/environment/servers to implementing the same. I am new to these concepts and finding it somewhat difficult to comprehend the information present on web. So looking for some help here as to where can i start.
Regards,
Rachael
First of all you should know uri of wsdl to generate a client. You can generate a client code in Eclipse File->New->Web Services->Web Service Client after pointing the wsdl.

How to start with writing a RESTful service?

I am trying to create a RESTful web service that accepts JSON arguments and gives out a JSON response.
What I want is to accept HTTP requests made to my URL endpoint.
Something like,
POST /the/endpoint HTTP/1.1
Host: mywebsite.com
{"name":"yourname", "department":"your_department"}
Do a DB read at the backend and give relevant parameters like, say Manager name, salary etc as a JSON object, as the response.
What's the best way to go about it? I was thinking of using Java servlets for this? Is there a better way?
PS - I am just getting started so detailed answers or links to tutorials as to how to implement it would be much appreciated.
Thanks.
Yes you can easily do this with Servlets and some Json Libs for Marshalling /unmarshalling the Json Object to Java Object.
You can make use of Json libs like
Jackson ,
Gson etc
But you must know that REST application doesnt end with just handling the request and response , but it needs to take care of other non-functional requirements like
Authentication
Authorization
Security etc
Building this from a scratch from a Servlet is overkill and waste of time when there are ready made frameworks that these things for you
My favorite is Spring MVC 3.0
Check their project site for more details
Just to show you how easy to set up one in Spring MVC , check this below tutorial
Spring 3 REST Tutorial
Pls rate the post if it helps , Cheers.
If you want to go with Java, I suggest that you take a look at JAX-RS... And since REST is a complex topic, here is a url with tons of informations on it. http://code.google.com/p/implementing-rest/
As a complete beginner, I believe the best way to implement a (nearly) RESTful API without having to read a lot is simply to implement the API just using HTML pages and HTML forms with the back-end processing to handle them.
The rules are:
Use <a> tags to provide links to related resources. (navigation)
Use <form> tags to initiate any kind of processing operation on the server. (actions)
You can then make it properly RESTful by using progressive enhancement to add Javascript AJAX requests that perform PUT, PATCH, and DELETE instead of using POST for those three (of course, keeping POST for creating resources where the client doesn't know the resultant URI).
You can then click around and test the API in a web browser! Tools like Selenium can automate this.
If you need to provide JSON, this can be added after the API has been designed and tested, although libraries exist to process HTML or XHTML responses too, so JSON isn't necessarily required for machine readability.
if you are using php with symfony try:https://github.com/FriendsOfSymfony/FOSRestBundle this lets you create a real REST full servicer very quick.
Vogella made my day very easy when i started Web services with an super example here with eclipse screen shots ..Have a look here.

gwt export to file

i have a problem with gwt application. i have an array of strings in the client application and i want to export it to a file, but it isn't probably possible so i have to use servlet, right? but i don't really know how.
It is quite unfortunate, given the advance of browser applications, that data produced by such applications cannot be saved by the user locally, but instead has to make e round trip to the server. It would be really helpful, I think, to adopt the data scheme (http://en.wikipedia.org/wiki/Data_URI_scheme) for such cases, and not only for images, which has proved itself quote useful. If this scheme is adopted a GWT app could build a link and provide the data to be saved as part of the href attribute of the tag.
Here's a guide on How to Call a Servlet in GWT.
Alternatively, use the GWT HTTP client to send a GET or POST request to the servlet.
In this case using servlet is a good idea or maybe RPC is better. What do you think? So far I wrote a separate servlet that writes an array of strings to a file. But I don't know how to connect to the gwt project. Will this created file be HttpServletResponse response in this case?

sudzc or wsdl2obj?

I know this question has been asked several times but the issue here is a little different.
In order for iphone to consume the WSDL, i tried to use wsdl2obj for but got the error as UNSINGED BYTE... during compilation and no help found on this over the internet.
Now when i try using the sudcz wsdl convertor, I am able to parse the wsdl and get the resulting XML but unfortunately, unable to get the rest as sudcz does classes dont read my xml property to generate proper objects.
Any help here?
Regards,
Accilies
I had some of the same problems. I had to setup structures in the web service and used these to return the data from the web service call. I was able to easily parse the returned XML.

How can I create a SOAP server in Perl?

I'm working with a third-party vendor who unfortunately requires that we set up a SOAP server to handle requests from them. I'm having some trouble finding the best way to go about this. One limitation I'm imposing is that it runs as a mod_perl2 handler. After some searching I've found that the best way may be to use XML::Compile and its SOAP classes but I'm having a tough time wrapping my head around it. Part of the problem is my limited understanding of SOAP and the documentation for most modules seems a bit cryptic to me.
So, can anyone give me some pointers, sample code, anything?
EDIT: we were also given a WSDL file to use, and this was not compatible with SOAP::WSDL ("unsupported global type found in ...
Looks like a rpc/literal WSDL, which is not supported by SOAP::WSDL)
EDIT: XML::Compile::SOAP complains "RPC encoded not supported by this version" when using the WSDL with XML::Compile::WSDL11. Can/should I not worry about the WSDL file?
If you have a limited understanding of SOAP, starting reading about SOAP before you worry about implementing it. There are lots of SOAP tutorials out there. Most of the documentation probably seems cryptic to you because you don't already know SOAP.
It's not that tricky of a process. It's not that different than any other web programming when it comes to the big steps:
You get a SOAP request, which is some XML.
You pull apart the XML to figure out what to do.
You put together some XML to send as a response.
You return the response.
XML::Compile will take care of most of the details for you.
Before you start writing your own server, you might consider writing a client for an existing SOAP server just to give yourself some practice.
I found two modules that can help you make soap server, but I never use its
https://metacpan.org/pod/XML::Compile::SOAP::Daemon
https://metacpan.org/pod/SOAP::WSDL::Server