uCosminexus Application Server, Web Service Development Guide
This section describes the web.xml included in the WAR file to be used in POJO Web Service.
When creating web.xml, specify the file name as web.xml and save directly under the WEB-INF directory configuring WAR files. The requirement of saving the web.xml file differs as per a value specified in the webserver.container.jaxws.webservice.no_webxml.enabled property of the user property file (usrconf.properties) that is used for J2EE servers.
The following are the definitions required to execute Web Services, examples of web.xml, and operations when web.xml is not included in a WAR file:
For specifying strict in the webserver.container.jaxws.webservice.no_webxml.enabled property to include web.xml in the WAR file, or for specifying none, create web.xml in such a way so that the following conditions are fulfilled:
<listener> <listener-class> com.cosminexus.xml.ws.transport.http.servlet.WSServletContextListener </listener-class> </listener> |
<servlet> <description>Endpoint servlet for Cosminexus JAX-WS</description> <display-name>Endpoint_servlet_for_Cosminexus_JAX_WS</display-name> <servlet-name>CosminexusJaxwsServlet</servlet-name> <servlet-class> com.cosminexus.xml.ws.transport.http.servlet.WSServlet </servlet-class> </servlet> |
<servlet-mapping> <servlet-name>CosminexusJaxwsServlet</servlet-name> <url-pattern>"/"+Service name of Web Service 1</url-pattern> <url-pattern>"/"+Service name of Web Service 2</url-pattern> ... <url-pattern>"/"+Service name of Web Service n</url-pattern> </servlet-mapping> |
An example of web.xml is as follows:
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" 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"> <description>Sample web service "fromwsdl"</description> <display-name>Sample_web_service_fromwsdl</display-name> <listener> <listener-class> com.cosminexus.xml.ws.transport.http.servlet.WSServletContextListener </listener-class> </listener> <servlet> <description>Endpoint servlet for Cosminexus JAX-WS</description> <display-name>Endpoint_servlet_for_Cosminexus_JAX_WS</display-name> <servlet-name>CosminexusJaxwsServlet</servlet-name> <servlet-class> com.cosminexus.xml.ws.transport.http.servlet.WSServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>CosminexusJaxwsServlet</servlet-name> <url-pattern>/TestJaxWsService</url-pattern> </servlet-mapping> <session-config> <session-timeout>60</session-timeout> </session-config> </web-app> |
When creating web.xml of version 2.5, specify 2.5 in the version attribute of the web-app element and specify http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd as the second location information in the xsd:schemaLocation attribute.
The above example is based on the assumption that the value of the following attributes is TestJaxWsService:
At this time, add / (slash) and code the value of the url-pattern element as /TestJaxWsService.
With the JAX-WS functionality of Cosminexus, if you do not specify strict or lax in the webserver.container.jaxws.webservice.no_webxml.enabled property to include web.xml in the WAR file, the processing will be performed considering that the web.xml with the following contents exist while invoking Web Services:
<?xml version="1.0" encoding="UTF-8"?> <!-- code the web-app element--> <description>Cosminexus JAX-WS Default web.xml</description> <display-name>Cosminexus_JAX_WS_Default_web_xml</display-name> <listener> <listener-class> com.cosminexus.xml.ws.transport.http.servlet.WSServletContextListener </listener-class> </listener> <servlet> <description>Endpoint servlet for Cosminexus JAX-WS</description> <display-name>Endpoint_servlet_for_Cosminexus_JAX_WS</display-name> <servlet-name>CosminexusJaxwsServlet</servlet-name> <servlet-class> com.cosminexus.xml.ws.transport.http.servlet.WSServlet </servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>CosminexusJaxwsServlet</servlet-name> <url-pattern>"/"+Service name of Web Service 1</url-pattern> <url-pattern>"/"+Service name of Web Service 2</url-pattern> : <url-pattern>"/"+Service name of Web Service n</url-pattern> </servlet-mapping> <session-config> <session-timeout>60</session-timeout> </session-config> </web-app> |
For "/" + Service name of Web Service 1, a string is defined with / (slash) that is added as a prefix to values of the following attributes:
The operations for all the Web Service Implementation Classes or the Provider Implementation Classes stored in the WAR file will be performed assuming that the url-pattern element exists.
When you specify lax in the webserver.container.jaxws.webservice.no_webxml.enabled property to include web.xml in a WAR file, and if the contents of the section 3.4(1) Definitions required for executing Web Services are not coded correctly in web.xml, invoke Web Services considering that the web.xml with the above contents exist, in the same way as you would consider when web.xml is not included. Note that the web.xml file that is considered in such cases will have the above mentioned contents excluding the contents of the session-config element.
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.