Monday, August 4, 2014

JBOSS EAP 5.1.2 & Sun Metro JAX-WS

Jboss does have their own web service implementation which is JBossWS-CXF, based out of Apache CXF. But if you are into JAX-WS metro stack you can simply use it with jboss.


1. Overide the class loader to load SUN Metro stack instead jboss supplied jax-ws version.


create “jboss-web.xml” file in “WEB-INF” folder with following content.


<?xml version=”1.0” encoding=”UTF-8”?>
<jboss-web>
    <context-root>/MyApp</context-root>
    <class-loading java2ClassLoadingCompliance=”false”>
        <loader-repository>
            org.myapp:loader=MyApp.war
            <loader-repository-config>
                java2ParentDelegation=false
            </loader-repository-config>
        </loader-repository>
    </class-loading>
</jboss-web>



2. Add WSServletContextListener listner to web.xml file


<listener>
       <listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
  </listener>



3. Add servlet and servlet mapping for WSServlet


<servlet>
    <servlet-name>WSServlet</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>WSServlet</servlet-name>
    <url-pattern>/*</url-pattern>
   <!—  <url-pattern>/services/*</url-pattern> —>
  </servlet-mapping>



You may now get your web service not only work but dynamic WSDL creation also working.

No comments:

Post a Comment