Auto code generator to consume web services from Android - java

I'm using ksoap2 to consume web services from Android projects. Everything is working fine but I miss some properties in the library which I think are pretty common.
In Visual Studio when adding a web service reference all the necessary code so you can consume the web service is created, and even more important, the necessary classes for the objects/types returned by the web service. The same can be done in XCode or in Eclipse when using Java EE.
The closer I get to this in Android is http://code.google.com/p/android-soap-enabler/wiki/FiveMinutesTutorial I tried but I had some problems and I let it go.
It's hard to believe that there is no standard way to solve this issue. I mean, I guess there exists so many Android Apps consuming web services, and no one has a better way than manually parse the xml response using the ksoap2 library? What finally makes it even weird, is that I didn't find anyone asking this question. Is it so strange what I'm asking? Am I the first one with this problem?
I would like to know if there is any tool/library/project/whatever which automatically creates the necessary code for consuming the web services.

Related

Writing a web service for SAP AS Java NetWeaver 7.5 and NWDS 7.5

I have recently started working in SAP part of the time. I believe our system is a little old by SAP standards--I think it's ECC6.0. The NetWeaver version is 7.5. We have both ABAP and SAP AS Java, and it is the AS Java portion I have a question about. I have been looking for a way to automate the import of role data into the portal. Currently, someone takes the file each day and uploads it using the import function in the portal. It is my understanding that SAP AS Java supports building web services, and I see that there are SAP java functions for accessing the UME, so my thought was to build a Java web service to do this. I have downloaded NWDS 7.5, and because I read that NetWeaver uses JAX-WS, I built a JAX-WS web service.
The problem I'm having is that I have no clue as to how to deploy the service/get it running/access it. When I try to find info in google, I come up with quite a few relevant hits, but many of the functions they talk about in NWDS don't seem to exist in the version I have. For example, one thing I commonly see is to use the "Web Service" option from the context menu of the java class you want to turn into a web service. My context menus don't have this option; they have mostly the standard options you see in Eclipse, with a few additions.
I did get my web service to deploy via NWDS via the deploy perspective, but while I can see the application on the server, I don't seem to be able to access it. Using https://host:port/web-service-name produces a directory listing that does not include my java classes. Also, I'm unsure as to whether I should deploy my application as a .war or a .ear, maybe that's part of the problem too? I have deployed to the server with both. Also, as someone who's familiar with deploying to Tomcat, I'm really not sure what's needed to get the SAP server to work with my app. The server complained, for example, about web.xml in the archive, and I'm not sure what to do about it.
All in all, I'm pretty confused. Does NWDS 7.5 still have support for building AS Java web services? Does it work differently from prior versions? What do I need to do to get this to work? Also, if there's a way to do a RESTful web service, that would be welcome.
So, as these things often seem to go, I had a big breakthrough and solved this problem a couple weeks after posting this question, the question I posted after months of struggling with this issue. Here is what I did to make things work; I haven't meticulously gone through what I did to make sure what I'm posting is accurate; I'm just going off what I remember, if there are inaccuracies, hopefully this Will at least be enough to get someone on the right track. If you have issues or questions with this process, please do contact me.
First off, thanks to Suncatcher for his response. I did use the "Java EE" perspective in Eclipse, and I didn't see the "Web Service" option in the context menu. If you have any thoughts on why this would be or suggestions on another perspective to use, I would love to hear about it. As a result of this, my process doesn't match the process given in the link you posted, but it does seem to work.
One thing I wish I would have understood is that SAP already has JAX-WS up and running for you. Everything is configured, and SAP will take care of configuring your class to run as a JAX-WS web service. All SAP is expecting is a class who's source code has been annotated with the appropriate JAX-WS annotations. Items like web.xml are not needed.
Create a new EJB 3.0 project for your web service. Make sure your web service class and its methods
have the appropriate JAX-WS annotations. (There are EJB annotations
added as well, and I'm not sure whether or not they are needed. I
left them in.)
Create an "Enterprise Application Project". This will
be used to build the EAR that contains your web service project. As
you create the project, make sure to select your web service project
to include in this project.
Right-click the project you just created
and click "export"; select the SAP EAR option.
Use the deploy
perspective of NWDS to deploy your EAR.
I had trouble finding the address of my web service. I used the "WS Navigator" feature to find it.
Once you have your web service up, you have the address, and you can successfully retrieve a WSDL, you can generate a client for it.

Android application Implement daily updates

I’m hoping this question hasn’t been asked before or that it isn’t too basic, but if it has please let me know and I will delete this question!
I have experience programming in Java but I am fairly new to programming for Android Applications (specifically on Eclipse). I’m trying to help a friend out with his business (which will inadvertently be my first Android app!). All that he wants me to do is develop an application where there will be a daily update with an inspirational image and quote. I’m sure it’s something that is extremely simple, but I’m unsure on how to provide continual updates to an application. Would I put it on a server? Can I upload it to some website (Google Drive, image sharing website, etc.) and somehow tell the app to continually grab the newest one? And then save old images and text onto the phone so they can access it anytime in the future?
If you could point me to source code that I could manipulate that would excellent! I learn best when I can alter existing syntax to see effects. I appreciate the help and hope to hear from you soon!
Would you suggest this to be a good example for me to look off of: http://developer.android.com/samples/BasicSyncAdapter/index.html
This isn't an update to the application itself, just sending new content to it. A trivial REST service calling to an HTTP server can send the information. The Spring Android RestTemplate or other similar client-side libraries make consuming REST services easy, and Spring MVC, Jersey, and dozens of other frameworks for Java and other languages can implement the entire server side of this in a few classes.

add web service reference to eclipse

I'm building a android application and I need to consume a web service. I am using eclipse as my ide.
Does Eclipse have a nice easy way to add the web service to the project like the way visual studio does?
Is there a plugin?
I tried this http://wsdl2javawizard.sourceforge.net/ but I cant find "Import Web Reference" in my latest version of eclipse
Thanks for the help
World,
In android/java nothing exist like add service or add webservice reference facility as you have in visual studio.
So, you need to first do analysis of following to proceed further:
1) Either you are using soap based webservice? or restful api?
A: If you are using soapbased service that is developed in dotnet then you need to use any free library to consume it like: (ksoap) i used 1 year ago.
B: similary if you are using restfull with json (then Gson is the Google library which is very easy and helpful.
I hope i have given you the direction now you can explore these yourself :)

How to create Web Services in Java (with Eclipse)

I am really really having hard time to create simple "Hello World" Web Service in Java. If you exclude several mobile Android mobile apps I have done, I am pretty new to Java environment.
First I tried Axis2 and that simply doesn't work out of the box. Fresh installation of Eclipse, Tomcat 6.0 and Axis2. Tried sample test app and it failed miserably. You can read about it here. My conclusion is that Axis2 simply doesn't work (maybe it used to work). I will try to go back to install older versions, maybe one will magically start working. I have to modify some old project at work that was using Axis2, so that's why I have to stick with it. I would hate to have to migrate to some other tool.
Then I ran on Oracle article Getting Started with JAX-RPC and I was thinking, cool, let's try that. Well, I just managed to get pissed off. After getting half way through the article and trying to write some simple test web service I realized that their code examples are poorly written. Missing brackets, wrong references, missing explanations, etc...
First of all, an interface should extend not implement. Am I right?
public interface SunRegPort implements java.rmi.Remote {
Also, this doesn't exist:
import java.xml.rpc.server.ServiceLifecycle;
But this does:
import javax.xml.rpc.server.ServiceLifecycle;
Well, I don't feel competent to criticize too much (cause of my level of knowledge about this subject of course), but after all I am suspicious that this article is complete JUNK and therefore I am not able to follow it.
Please somebody tell me that I am wrong and if anybody has some advice or link to some How-To page that talks about web services, I would appreciate.
Thanks.
The terminology Web Services is pretty vague. In Java, the modern and reasonably easy way to do this is by annotating classes.
I would recommend that first, you decide whether you want to implement:
SOAP Web Services -> look at JAX-WS
REST Web Services -> look at JAX-RS
Once you have chosen the "type" of Web Services, choose the library that implements the specification.
The Wikipedia entries list a few of these implementations. Apache CXF (complete but a beast), Jersey (popular) and Restlet are very common choices. I personally like the JBoss implementations as well for JAX-WS.
For JAX-WS with Apache CXF, here is a quick start tutorial that looks pretty good (untested)
For JAX-RS with Jersey, try this
Unless you have strong reasons to do otherwise (for instance you need to call an existing system), use REST which is simpler and leaner.
I would recommend you to check out the CXF project by apache. It's quite easy to use and should help you to set up a webservice.
There is a nice guide to Hello world set up.
http://cxf.apache.org/docs/a-simple-jax-ws-service.html
If you're still interested in giving Tomcat a shot, here is a tutorial on youtube of making a very basic "Hello world" example using Eclipse. It leaves a lot to learn; but it looks like it will at least get you started.
FYI, the version of Eclipse used is slightly outdated. So some of the menu options may not be exactly the same:
http://www.youtube.com/watch?v=EOkN5IPoJVs
Also, the meaning of "Web Service" can be subjective. So, to be specific; this just shows you how to get a basic HTTP endpoint started on your local machine.
If you are not tied to Eclipse, give NetBeans a shot. I think it's much better for Web Services in Java.
Web Services are most widely implemented examples of Service Oriented Architecture (SOA). A service contract is defined with the help of SOAP and Web Service Definition Language (WSDL) and that is published for other applications to use.
In this article we will see how we can create web service and web service client in java.
http://www.opencodez.com/java/how-to-build-and-deploy-web-service-and-client-in-java.htm

Web services clients in Java

I'd like you to list all the solutions available to generate web-service clients in Java platform.
I need to extract the structured information from the web-service to work with.
What do we have in the box? Preferably available as Eclipse plugins.
Axis2
JBossTools
Apache CXF
What else ?
The problem here is that most tools do not work with web-services I need to consume.
Apache CXF does not generate the client.
JBoss only partially does the job.
I would like to try something and find what really works with particular web services.
java.sun.com/webservices/.../wsit/.../Examples_glassfish6.html
this is for creating web services
No one gave a clear answer yet.
I got one advice: always try different versions of a framework, and try the latest.
It may sometimes be the key answer.

Categories