> My peers and I have been discussing my difficulties in generating a
> WAR file from the generated artifacts (from jax-ws). We are unsure if
> my WAR file is un-useable, my artifacts are incomplete, or if the WAR
> file is incompatible with my application servers. I have tried using
> WebLogic 9.2 and Apache 5.5 (consecutively, not concurrently; both
> local installations).
For Tomcat, you need to have something similar to the following lines in
your web.xml.
<listener>
<listener-class>
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>myservletname</servlet-name>
<servlet-class>
com.sun.xml.ws.transport.http.servlet.WSServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>myservletname</servlet-name>
<url-pattern>/myurl</url-pattern>
</servlet-mapping>
Also, you need to have a sun-jaxws.xml file in your WEB-INF directory
(as far as I know you may not need this file for other application
servers).
<?xml version="1.0" encoding="UTF-8"?>
<endpoints version="2.0"
xmlns="
http://java.sun.com/xml/ns/jax-ws/ri/runtime">
<endpoint implementation="ws.HelloService"
name="HelloService" url-pattern="/myurl"/>
</endpoints>
> If anyone would be willing to help, below is a sample of one of my
> trials. I am new to web services, so I am willing to accept that
> anything or everything I have done may be completely wrong. Also, I
> am trying to avoid any use of ant as I always encounter numerous
> headaches when I attempt to use it; however, if ant is the only way to
> straighten out my mess, I will manage.
In order to avoid calling wsgen you may annotate your service class with
the following annotation.
@SOAPBinding(parameterStyle=SOAPBinding.ParameterStyle.BARE)
But this only works if your service methods have only one single
parameter. (The single parameter could be a complex type so if your
design allows you may wrap all the parameters in a structure but this
may not be a good design in some or many cases.)
One arguable practice I do in test projects (in order to avoid using
ant) is to set the Eclipse classpath to the WebContent/WEB-INF/classes
directory. I also link the projects Webcontent directory to a directory
under Tomcat's webapp directory . These allow any changes reflected to
Tomcat server side quite quickly so I can test new changes without
generating war files and redeploying them.
Based on my recent experiences, I can also recommend you to use NetBeans
at least until you have a good understanding of jaxws. Compared to
Eclipse, Netbeans supports jax-ws in a user friendly manner and
generates all the necessary ant targets. You may for example start with
the following tutorial
http://www.netbeans.org/kb/55/websvc-jax-ws.html
If you go the 'Files' view at the end of the tutorial you can see which
ant targets netbeans generated for your project (under the nbproject
directory; build-impl.xml, ant-deploy.xml).
Regards,
Mahmut