Problem when testing a SOAP web service

11

I am implementing a SOAP web service in Java in an application that uses Struts in the presentation layer and I have trouble testing it. The IDE that I am using is Netbeans and the service was done using the assistant provided by the IDE. The application deploys correctly on a GlassFish server and the web service that I am implementing is exposed appropriately. The generated WSDL address is:

link

The problem occurs when I want to try the service by changing the URL to link , link that should show me a page for enter the necessary data to test the service, but redirects me to the information page of the endpoint ( link ). In the file struts.xml I have already indicated to Struts that exclude the routes / webServices / * 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>

Anything additional I have to add to exclude the URL and to be able to prove the web service or I have something bad in the regular expressions ?. I have already tried the service using SoapUI and the like, but I would like to be able to perform the tests from the browser through the URL.

    
asked by dwarandae 04.12.2015 в 23:44
source

1 answer

4

Glassfish uses the servlet org.glassfish.webservices.JAXWSServlet internally. It finds 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 client with wsimport from the WSDL obtained with a request by adding ?WSDL to the URL and generates the HTML for the test page.
  • endpoint ? WSDL : This generates the WSDL using an instance of com.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 the com.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, simply write down the class that implements the web service with @WebService without the need to map any servlet And then you will have the test page available. *

────────────
* It is important to disable this option in productive environments, either through the file sun-web.xml or sun-ejb-jar.xml specifying false in the element debugging-enabled .

    
answered by 05.12.2015 / 04:25
source