I am implementing a SOAP web service in Java in an application that uses Struts in the presentation layer and I am having trouble testing it. The IDE I'm using is Netbeans and I did the service using the wizard provided by the IDE. The application successfully deploys to a GlassFish server and the web service I'm implementing is properly exposed. The address of the generated WSDL is:
http://localhost:8080/Drugs/webServices/TestWSDL?WSDL
The inconvenience occurs when I want to test the service by changing the URL to http://localhost:8080/Medicamentos/webServices/TestWSDL?Tester , a link that should show me a page to enter the necessary data to test the service, but it redirects me to the page endpoint information ( http://localhost:8080/Medicamentos/webServices/TestWSDL ). In the struts.xml file I have already told Struts to exclude the /webServices/* routes so that they are handled by the servlet in charge of the web service:
<constant name="struts.action.excludePattern" value="/webServices/.*"/>
My web.xml file:
<display-name>Medicamentos</display-name>
<!-- Spring/Hibernate conf -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--Struts filter and interceptor -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Sticky session -->
<distributable/>
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>TestWSDL</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>TestWSDL</servlet-name>
<url-pattern>/webServices/*</url-pattern>
</servlet-mapping>
Do I need to add anything else to exclude the URL so I can test the web service or do I have something wrong with the regular expressions? I've already tested the service using SoapUI and the like, but I'd like to be able to test from the browser via the URL.
Glassfish uses the servlet internally
org.glassfish.webservices.JAXWSServlet
. It looks for two strings in the query-string of the request URL:endpoint
?
Tester
: This forwards the request to another servlet ,org.glassfish.webservices.monitoring.WebServiceTesterServlet
which generates a clientwsimport
from the WSDL obtained with a request appended?WSDL
to the URL and generates the HTML for the test page.endpoint
?
WSDL
: This generates the WSDL using an instance ofcom.sun.xml.ws.api.streaming.XMLStreamWriterFactory
and writes it to the request.However, in your case, you have registered the
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
and thecom.sun.xml.ws.transport.http.servlet.WSServlet
, which does not have that option.If the Glassfish you are using supports Java EE 6 or higher, just annotate the class that implements the web service with
@WebService
no need to map any servlets . And then you will have the test page available.*────────────
* It is important to disable this option in production environments, either through the file
sun-web.xml
or bysun-ejb-jar.xml
specifyingfalse
in thedebugging-enabled
.