I am trying to create a Webservice implementation deployed on a WebSphere 8.5 application server.
I already created the skeleton and all the stubs but I don't know how to package my application.
I noticed that using axis2-wsdl2code-maven-plugin a services.xml file is created and this should replace the old WSDD file from axis1. However I don't know where should I place the services.xml and how to set web.xml (if it is needed).
Everything should be packaged in a simple war file.
I cannot find any simple documentation for this.
UPDATE:
I was able to deploy my application but I cannot reach neither the service nor its wsdl (the WSDL is not present inside the archive).
When I'm trying to reach my webservice i get:
org.apache.axis2.AxisFault: The service cannot be found for the
endpoint reference
I have the following services.xml file, located under WEB-INF/services fodler of my WAR archive.
<?xml version="1.0" encoding="UTF-8"?><!-- This file was auto-generated from WSDL --><!-- by the Apache Axis2 version: 1.6.2 Built on : Apr 17, 2012 (05:33:49 IST) --><serviceGroup>
<service name="PagamentoBollettinoPostaleInf">
<messageReceivers>
<messageReceiver mep="http://www.w3.org/ns/wsdl/in-out" class="myservice.PagamentoBollettinoPostaleInfMessageReceiverInOut"/>
</messageReceivers>
<parameter name="ServiceClass">myservice.PagamentoBollettinoPostaleInfSkeleton</parameter>
<parameter name="useOriginalwsdl">true</parameter>
<parameter name="modifyUserWSDLPortAddress">true</parameter>
<operation name="getPagamentoBollettinoPostaleInf" mep="http://www.w3.org/ns/wsdl/in-out" namespace="******">
<actionMapping>urn:getPagamentoBollettinoPostaleInf</actionMapping>
<outputActionMapping>urn:getPagamentoBollettinoPostaleInfResponse</outputActionMapping>
</operation>
</service>
</serviceGroup>
This is my WEB.XML file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>inviaAnomalia</display-name>
<servlet>
<display-name>Apache-Axis Servlet</display-name>
<servlet-name>AxisServlet</servlet-name>
<servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/servlet/AxisServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>*.jws</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>
This is the endpoint i am trying to connect to:
http://localhost:9080/war_context_root/services/PagamentoBollettinoPostaleInf
This happens when I try to get the WSDL file of my webservice by connecting to: http://localhost:9080/war_context_root/services/PagamentoBollettinoPostaleInf?wsdl
SOLVED
The solution was to follow the steps shown here: http://maksim.sorokin.dk/it/2011/01/13/axis2-maven-servlets-tomcat/
Then, in order to deploy correctly, WSDL and services.xml descriptor file must be placed inside:
WEB-INF/services/<ServiceName>/META-INF
Furthermore, disabling IBM JAX-WS Engine as suggested by Bruce T. and setting the classloader as shown in the following image solved the issue.
Related
I have an Axis2 based web service which I deployed in Tomcat.First I downloaded axis2.war & placed it in Tomcat's webapps folder.It created axis2 folder & its sub-folders.In the WEB-INF sub-folder of Axis2, in the services sub-folder I place my .aar file.Then in my browser I go to http://localhost:8080/axis2. It has a link services, which lists out all the services.Suppose my service is HelloWorldService. So the path where it is accessible is
http://localhost:8080/axis2/services/HelloWorldService
But I do not want to reveal to world that my web service is driven by Axis2. Suppose I want the path to be
http://localhost:8080/abc/services/HelloWorldService
How to do that? Do I have to rename axis2 folder to abc. I also have an web application abc deployed in the same Tomcat. Do I copy content of axis2 sub-folder to abc. I tried that, did not work.
I also have an web application abc deployed in the same Tomcat. Do I copy content of axis2 sub-folder to abc.
You're thinking in right direction and yes, you have to copy all content(100% is not required, but its better you do it to start with) of the Axis2.war to abc except web.xml.
You have to merge, axis2.war/WEB-INF/web.xml content with abc/WEB-INF/web.xml, by copying following to respectively inside <web-app> XML tag.
<servlet>
<display-name>Apache-Axis Servlet</display-name>
<servlet-name>AxisServlet</servlet-name>
<servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class>
<!--<init-param>-->
<!--<param-name>axis2.xml.path</param-name>-->
<!--<param-value>/WEB-INF/conf/axis2.xml</param-value>-->
<!--<param-name>axis2.xml.url</param-name>-->
<!--<param-value>http://localhost/myrepo/axis2.xml</param-value>-->
<!--<param-name>axis2.repository.path</param-name>-->
<!--<param-value>/WEB-INF</param-value>-->
<!--<param-name>axis2.repository.url</param-name>-->
<!--<param-value>http://localhost/myrepo</param-value>-->
<!--</init-param>-->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<display-name>Apache-Axis AxisAdmin Servlet (Web Admin)</display-name>
<servlet-name>AxisAdminServlet</servlet-name>
<servlet-class>org.apache.axis2.webapp.AxisAdminServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/servlet/AxisServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>*.jws</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisAdminServlet</servlet-name>
<url-pattern>/axis2-admin/*</url-pattern>
</servlet-mapping>
Hope it works for you! If it doen't work update your question and I could refocus the answer.
I've already developed a SOAP web service in Java with apache cxf and now I've to develop the same services in RESTful.
I have some troubles to deploy the web service on my tomcat. In fact, I don't know how should I configure my web.xml or any other XML file.
There are many examples online but everything I've tried so far doesn't work.
To build the project, I use an Ant build tool.
Anyone knows some good tips?
Here my service class used to test tutorials
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
#Path("/book")
public class BookService {
#GET
#Path("{id}")
#Produces({"application/xml","application/json"})
public Book getBookForId(#PathParam("id") int id) {
Book book = null
book = DB.getBookForId();
if(book == null){
return Response.status(Response.Status.BAD_REQUEST).build();
}else{
return Response.ok(book).build();
}
}
}
And my web.xml looks like this most of the time :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>REST</display-name>
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
Apache CXF's example and other examples are "easy" to understand but the fast is that what i've done until now won't work.
My web service is deployed on my tomcat but everytime there is error like this :
Servlet.service() for servlet [Jersey Web Application] in context with path [/WebServices] threw exception [L''exécution de la servlet a lancé une exception] with root cause
java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:669)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
I know that this kind of error are stupid btu i don't get it Zzz.
I have to use jdk 1.6.0.45 so i can't try example which use jdk 1.7 and higher version. The fact is most of example tell to use Jersey 2.18...
I create a web service using net beans 7.1 and Jboss.
i am following the steps of this tutorial:
http://campuscurico.utalca.cl/~pabrojas/?page_id=192
But when i deploy the project with glassfish i go to:
http://localhost:8080/ProjectName/webServiceName?WSDL
And it show me the wsdl.
But when i deploy the project with Jboss 6.1 Final, and i go to the url:
http://localhost:8080/ProjectName/webServiceName?WSDL
The page show me Estado HTTP 404 - /
but when i go to the:
http://localhost:8080/ProjectName/
Show me the index jsp page
What is my problem, why i can't deploy the project with jboss?
Who can help me?.
Thanks
I do not if i need configure my web.xml
I have this web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>
Have a look in the generated WSDL in your JBOSS. You can find it in your JBOSS Home directory:
JBOSS6/standalone/data/wsdl...
In the WSDL the url to your wsdl is specified in the soap:address tag.
If no wsdl is stored in your jboss you have to share some more information about your web service files.
We have a Spring 3 MVC webapplication, and we are trying to expand it with Web Services.
I have now tried with JAX-WS Web-services, annotating WebService and WebMethod on the appropriate places.
I do have a dispatcher mapped in my web.xml. This is the standard spring DispatcherServlet. And its config: dispatcher-servlet.xml is working perfectly fine for the MVC stuff.
The problem comes when I try to expose the WebServices. I do this by adding the following bean to the dispatcher-servlet.xml:
<bean class="org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter">
<property name="baseAddress" value="http://localhost:8080/service/" />
</bean>
If this bean is added. Then the WebServices works perfectly, but all the MVC stuff stops working.
So my second try was to create 2 dispatchers. One named mvc-dispatcher and one webservice-dispatcher. Each of them mapped to respectivly /mvc and /ws. And then put only the SimpleJaxWsServiceExporter in the webservice-config and only the standard MVC stuff in the other one.
But still the same problems.
I can only get the MVC to work if I disable/comment-out the web-service dispatcher.
I cant belive this is supposed to be so complicated... What am I not getting?
Any help would be greatly appriciated.
I cant find any decent tutorials doing JAX-WS and spring 3 MVC...
Thanks in advance!
I'm assuming by dispatcher you mean a spring dispatcher, I'd recommend against that. Just have the JAX-WS be a different servlet on it's own, i.e.
https://cxf.apache.org/docs/a-simple-jax-ws-service.html
Then if you need to allow Spring beans to be injected extend SpringBeanAutowiringSupport as in this example.
How to make an #WebService spring aware
Hope this helps!
You can use Apache CXF that implements the JAXWS Specification has a very good integration with Spring, actually CXF use behind the scenes Spring.
In practice you could proceed in this way:
in your web.xml you have configure the cxf servlet as below
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
....
<servlet>
<description>Apache CXF Endpoint</description>
<display-name>cxf</display-name>
<servlet-name>cxf</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cxf</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping>
</web-app>
Apache CXF configuration
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/bindings/soap
http://cxf.apache.org/schemas/configuration/soap.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath*:META-INF/cxf/cxf-extension-*.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<jaxws:endpoint
id="yourService"
implementor="#yourService"
address="/yourAddres">
</jaxrs:server>
</beans>
your bean
#Service
#WebService(serviceName = "soapSvnClientService")
public class SoapSvnClientService {
#WebMethod(operationName = "service")
public void service(#WebParam String param1,
#WebParam String param2){
....
}
}
I hope that this can help you
I have created a cloundfoundry app using Spring. However, my jsp files are being rendered as pure text (as if Tomcat is not executing the source code). The browser shows the source when requesting a particular URL.
File structure
webapps
-jsp
-javascripts
-css
-WEB-INF
web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:META-INF/spring/applicationContext*.xml</param-value>
</context-param>
<welcome-file-list>
<welcome-file>/jsp/index.jsp</welcome-file>
</welcome-file-list>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Handles Spring requests -->
<servlet>
<servlet-name>Honesty</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/spring/webmvc-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Honesty</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
spring config:
<!-- Turns on support for mapping requests to Spring MVC #Controller methods
Also registers default Formatters and Validators for use across all #Controllers -->
<mvc:annotation-driven/>
<context:annotation-config />
<mvc:default-servlet-handler/>
Thanks for any insight you can provide. Its as if Tomcat is not serving the request as the JSP source is showing, not a JSP rendered page.
The response headers show nginx as the server:
Connection:keep-alive
Date:Mon, 30 Jul 2012 03:58:16 GMT
ETag:W/"611-1343620259000"
Keep-Alive:timeout=20
Server:nginx
Are you using Spring MVC? I suppose you are putting the JSP in some resource directory which can be accessed. Would like to see your spring configuration file and your project structure.
The problem was my servlet mapping of "/*". switched to just "/" and now everything works as expected.