Thursday, August 26, 2010

metro web services

installed JDK 1.6.0.21
metro 2.1

top down approach i.e. starting from WSDL

0. assumption
you have (prepared) WSDL

1.
starting wsimport I get an error message saying that JAX-WS2.2 is required while JAX-WS2.1 is actually available; suggestion either to use -Xendorsed
other solution - to put webservices-api.jar from metro/lib to endorsed lib
(it is interesting that system variable java.endorsed.dirs is not taken into account. endorsed lib in java_home\jre\lib is working though

other problems met
definitions of faults in WSDL

wsimport generates Service Endpoint Interface aka SEI e.g.
@WebService(name = "GRIPSMX", targetNamespace = "http://jetsystems.com/GRIPSMX/")
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
@XmlSeeAlso({
ObjectFactory.class
})

2.
to implement it - create a class that implements the interface
(so called Service Implementation Bean aka SIB)
with annotation
@WebService(endpointInterface = "com.jetsystems.gripsmx.GRIPSMX")
and implement the actual web service methods

3. deployment

see
https://jax-ws.dev.java.net/guide/Deploying_Metro_endpoint.html
Deployment Metro Endpoint


a jax-ws web service is deployed as a separate web application with following stucture
WEB-INF/classes/ containing service endpoint interface (SEI) and SIB
WEB-INF/sun-jaxws.xml JAX-WS RI deployment descriptor
WEB-INF/web.xml Web deployment descriptor
WEB-INF/wsdl/[subdir with a name = of SIB]/ WSDL and XSD

e.g.
GRIPSMX/WEB-INF/classes/
GRIPSMX/WEB-INF/sun-jaxws.xml
GRIPSMX/WEB-INF/web.xml
GRIPSMX/WEB-INF/wsdl/GRIPSMXImplementation/GRIPSMX.wsdl
GRIPSMX/WEB-INF/wsdl/GRIPSMXImplementation/GRIPSMX.xsd

e.g. sun-jaxws.xml

<?xml version="1.0" encoding="UTF-8"?>
<endpoints version="2.0" xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime">
<endpoint implementation="com.jetsystems.gripsmx.GRIPSMXImplementation" name="GRIPSMX" url-pattern="/GRIPSMX"/>
</endpoints>

and web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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_2_5.xsd">
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>GRIPSMX</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>GRIPSMX</servlet-name>
<url-pattern>/GRIPSMX</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

where url-pattern in sun-jaxws.xml must match url-pattern in web.xml

http://localhost:8080/GRIPSMX/GRIPSMX?wsdl

No comments:

Post a Comment