Webservice from WSDL using Eclipse - eclipse

I have a WSDL file and I would like to create a webservice from that using Java ("Contract first approach"). I used the WSImport-Tool from JAX-WS (Java version 1.6.0_07) on the command line to generate Java-code stubs. This worked fine and I received the following Java files:
Add.java
AddResponse.java
ObjectFactory.java
package-info.java
Test.java
TestPortType.java
But how do I go on from here?
I am using Eclipse. There I could set up a new "Dynamic Web Project" with Target Runtime = "Tomcat 7.0". In Configuration do I have to choose "Axis2"? (Tomcat 7 and Axis2 are already setup locally).
I am lost at this point and do not know how to keep going.
Does it make it easier to create the webservice using Axis2 or do you recommend using JAX-WS? Or is there an even better option?
How and where do I include my WSDL file so it gets deployed to Tomcat 7?

Related

deploying spring mvc web app to tomcat: classpath issue

I am developing a small web app using Spring MVC framework. Basically, the app provides web interface, where user can upload XML file and verify it against specific XSD file. I put my XSD file within "src/main/webapp/XSDfoler". I put this folder into my Tomcat's classpath. (I am using Tomcat embedded into my Eclipse). In my code, in order to access my XSD file I simply used
ClassPathResource("myXSD.xsd");
It works fine. Now, I created a .war file from my webapp and tried to deploy it to another standalone Tomcat. When trying to run it, it give NullPointer exception since it cannot locate "myXSD.xsd" file. So as I get it, I have to somehow include this file into classpath of this standalone Tomcat instance. I looked for some nice step by step tutorial or article explaining how to deploy webapp to a standalone Tomcat server after doing the development in IDE with embedded Tomcat. Could anyone please explain/help. Thanks!
Try
ServletContext context = httServletRequest.getSession().getServletContext();
InputStream is = context.getResourceAsStream("/XSDfoler/myXSD.xsd");
alternatively use getResource() instead of getResourceAsStream()

gwt beginner- getting error when I make an RPC call on server- same code works in gwt dev mode

I have created a simple gwt application (with gwt 2.4) that makes a single RPC call.
When I run this in GWT Dev mode, it runs fine, however when I try to run this on a server-
this is the message that I get --
POST http://app.sparkcrawler.com/com.arvindikchari.auth.App/AuthenticationService 404 (Not Found)
I have copied all files from the WAR folder in my Eclipse GWT project, to the web server's folder. The web server uses Tomcat 5.5(with Cpanel control panel). I copied these files, after successfully compiling the files ("GWT Compile Project")...
What have i done wrong here? Have i missed some files? I have copied everything from war folder, including "WEB-INF" folder and its contents, to the web server.
I think, copying the Eclipse project's WAR folder is not the appropriate way to deploy a GWT application to a server.
You first have to compile for production mode (see Understanding the GWT compiler), then with the resulting JavaScript files, create a WAR including server side classes which you can deploy to a Tomcat server. (See Deploy a GWT Application)
You can use Ant or Maven to automate this process.

jaxWS issue on Netbeans 6.5 and Glassfish V2

i am not able to build Web Service Client, it is showing an error msg :You are running on JDK6 which comes with JAX-WS 2.1 API, but this tool requires JAX-WS 2.2 API. Use the endorsed standards override mechanism (http://java.sun.com/javase/6/docs/technotes/guides/standards/), or set xendorsed="true" on .
BUILD FAILED (total time: 0 seconds)
can any one help me out to solve this ...
Thanks in Advance :)
Are you running on Unix? Is the wsimport in your path in the glassfish directory or the Java install directory? I seem to remember getting this and changing my path so I got the wsimport from glassfish.
I don't know main cause but i think sometimes IDE causes that. Deleting WS reference and adding ws client again works for me sometimes.
Just click on netbeans generated error link (by clicking on it, netbeans will open jaxws-build.xml & goes to wsimport tag definition line) & add attribute xendorsed="true" somewhere in "wsimport" tag.
Or you can download & add JAX-WS 2.2 API jar file in your project classpath.
Check the JDK configuration being ran by the IDE,
When using Netbeans,
Step 1:
Find the Netbeans.conf file (C:\Program
Files\NetBeans7.0\etc\netbeans.conf)
Step 2:
Change "netbeans_jdkhome" to point to the newer JDK (i.e.
netbeans_jdkhome="C:\Program Files\Java\jdk1.7.0_80")
Note: Try similar steps for other IDEs

No web.xml in Eclipse + Glassfish v3?

I created a simple "hello world" servlet in Eclipse (helios) + Glassfish v3. I am using Glassfish's plugin for eclipse It seems there is no web.xml but a sun-web.xml in the WEB-INF/ folder. This is my first time with glassfish but was a bit surprised at the absence of web.xml - so here are some of the problems:
Where do I check for url-mappings for the servlet? On creating a new Servlet in Eclipse it asks me for a URL-mapping but I'm unable to find it anywhere in any .xml file where I can tweak the settings.
If there isn't any web.xml, creating it from scratch will be quite error prone. What do you suggest? Google for a sample and play around? Shouldn't one be auto-created?
Has anyone encountered this? I tried looking up the difference between web.xml and sun-web.xml but the results weren't at all enlightening. I wouldn't want to learn another xml for configuration purposes and that too glassfish specific.
We have to configure servlet contexts, mappings etc especially during development/testing but the sheer absence of web.xml has me stumped.
Eclipse allows you to not create a web.xml file when you create Dynamic Web Project for Java EE 6, since the Java EE 6 spec (in general) and Servlet 3.0 spec (in particular) attempt to de-emphasize deployment descriptors.
You can use annotation to provide all the data that had been included in the web.xml file. The Javadoc for the Servlet 3.0 annotations is pretty obtuse. You should read through the Servlet 3.0 spec from the jcp.org site to get a bit more explanatory text.
To change the url-mapping for a Servlet 3.0 servlet, the first place to look is in the source code for the servlet. Look for (and change) the value of the urlPatterns element.
If you are trying to create a web app based on Servlet 3.0, try to avoid creating a web.xml file.
The sun-web.xml/glassfish-web.xml file is used to 'finish' the description of a war file for deployment into a GlassFish container.
One other note about the annotations like WebServlet... they do not integrate your annotated class into the class hierarchy, so the correct use of #WebServlet would look like
#WebServlet(
name = "MyServlet",
urlPatterns = {"/path_to_servlet"}
)
public class MyServlet extends HttpServlet {}
If you find you do need a web.xml file, you can context-click on the deployment descriptor in the Project Explorer view and there should be an option "Generate Deployment Descriptor Stub". That will create a web.xml for you with the display-name and welcome-file-list elements.
It seems that it's a bad habit to click "Finish" when you create a 'New > Dynamic Web Project' - You should keep clicking 'next' and go the last window-pane where you select "generate web.xml deployment descriptor" - seems it's unchecked by default.
Well that says I've been a bit rusted with creating web-apps. And here I thought it was a glassfish specific issue.
Because of Glassfish 3.x is fully certified Java EE 6 server, it supports Servlets 3.0. Starting from Servlets 3.0, it is possible to specify web.xml settings through annotations.
For example
#WebServlet(
name = "MyServlet",
urlPatterns = {"/path_to_servlet"}
)
public class MyServlet {}
To add to what TMN said, I noticed that the project explorer would not show the Deployment Descriptor until I performed an SVN update for some reason. If you have that problem, try updating your code. I was on the HEAD revision already but for some reason the update showed that view.

how to implement sample jms, springs program in my eclipse

I'm new to jms and springs and eclipse as well. i'm trying to implement jms example using Springs in MyEclipse 7.1, and i have been referring the following url.
http://java-x.blogspot.com/2006/12/implementing-jms-with-spring-messaging.html
But Iam unable to understand how to execute the program, it contains a servlet but does not have any html or jsp page, should i create a web project for it or java application? How do i run the program.
Thanks and Best Regards.
You should create a web project to hold the servlet. A web project will have a directory for java source and a directory for web content (images, html, jsp, etc.). Make sure that you put the servlet code inside the java source directory. You will also need to register the servlet in web.xml unless it is a Java EE 5 servlet with annotations.
To run your servlet, right click on it and select Run As -> Run on Server