6 Replies Latest reply on Jun 3, 2016 3:38 PM by moic

    WSDL Override in Wildfly 10.0

    moic

      Hello, I am trying to make a web service. When I deploy my project, Wildfly auto generates a .wsdl. file. How can I supply my own? I notice when I run server it says this:

       

      09:34:44,136 INFO  [org.jboss.ws.cxf.metadata] (MSC service thread 1-1) JBWS024061: Adding service endpoint metadata: id=ProjectWebService
       address=http://localhost:8080/ProjectName/ws/oop/hello
      implementor=oop.cloudlet.ws.impl.ProjectWebServiceImpl
       serviceName={http://impl.ws.cloudlet.oop/}ProjectWebService
       portName={http://impl.ws.cloudlet.oop/}ProjectWebServiceImplPort
      annotationWsdlLocation=null
      wsdlLocationOverride=null
      mtomEnabled=false
      
      
      
      

       

      There is a 'wsdlLocationOverride' element there. How do I use it so it is not null, but the location of my wsdl? I am doing this on Eclipse Mars 2. Here are my files if they might help:

       

      ProjectWebService.java

      package oop.cloudlet.ws;
      
      import javax.jws.WebMethod;
      import javax.jws.WebParam;
      import javax.jws.WebResult;
      import javax.jws.WebService;
      import javax.xml.bind.annotation.XmlElement;
      
      @WebService
      public interface ProjectWebService
      {
          @WebMethod
          @WebResult(name="response")
          public String hello(@WebParam(name="stringOne") @XmlElement(required=true) String param1, @WebParam(name="stringTwo") @XmlElement(required=true) String param2);
      }
      
      
      
      
      

       

      ProjectWebServiceImpl.java

      package oop.cloudlet.ws.impl;
      
      import javax.jws.WebService;
      import oop.cloudlet.ws.ProjectWebService;
      
      @WebService(endpointInterface = "oop.cloudlet.ws.ProjectWebService", serviceName="ProjectWebService")
      public class ProjectWebServiceImpl implements ProjectWebService
      {
          public String hello(String param1, String param2) {
               return param1 + param2;
          }
      }
      
      

       

      web.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns="http://xmlns.jcp.org/xml/ns/javaee"
          xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
          version="3.1">
      
          <display-name>ProjectName</display-name>
      
          <welcome-file-list>
              <welcome-file>index.jsp</welcome-file>
          </welcome-file-list>
      
            <!-- HELLO SERVICE -->
            <servlet>
              <servlet-name>ProjectWebService</servlet-name>
              <servlet-class>oop.cloudlet.ws.impl.ProjectWebServiceImpl</servlet-class>
            </servlet>
         
            <servlet-mapping>
              <servlet-name>ProjectWebServiceS</servlet-name>
              <url-pattern>/ws/oop/hello</url-pattern>
            </servlet-mapping>
      
      </web-app>
      
      
      
      

       

      Would I have to add anything to web.xml to supply the location of my wsdl? Will I need anything else besides the wsdl file that Wildfly also auto-generates? Any help would be appreciated! Thank you!

        • 1. Re: WSDL Override in Wildfly 10.0
          nickarls

          You can use the wsdlLocation attribute of the @WebService annotation

          • 2. Re: WSDL Override in Wildfly 10.0
            moic

            I would put that in ProjectWebServiceImpl.java or somewhere else? The .wsdl has an embedded schema inside with two messages (send and sendResponse). How would that work out?

            • 3. Re: WSDL Override in Wildfly 10.0
              nickarls

              Yes, that's where the annotation appears to be.

              I would guess that if all wsdl documents and fragments are in the same location (perhaps under WEB-INF) and references are correct without any wrong hardcoding, they should resolve normally

              • 4. Re: WSDL Override in Wildfly 10.0
                moic

                Thank you very much. I was able to use my wsdl file. Another question if you don't mind, since my wsdl file has its own schema, how would I format my ProjectWebService.java and ProjectWebServiceImpl.java? For example, I have this right now:

                 

                ProjectWebService,java

                package oop.cloudlet.ws;
                
                import javax.jws.WebMethod;
                import javax.jws.WebResult;
                import javax.jws.WebService;
                import javax.xml.bind.annotation.XmlElement;
                
                @WebService
                public interface ProjectWebService
                {
                    @WebMethod
                    public String send();
                }
                
                

                 

                ProjectWebServiceImpl.java

                package oop.cloudlet.ws.impl;
                
                import javax.jws.WebService;
                import oop.cloudlet.ws.ProjectWebService;
                
                @WebService(endpointInterface = "oop.cloudlet.ws.ProjectWebService", portName="ProjectWebServicePort", serviceName="ProjectWebService", wsdlLocation="test.wsdl", targetNamespace="test.xsd")
                public class ProjectWebServiceImpl implements ProjectlWebService
                {
                    public String send() {
                        return "hi";
                    }
                }
                
                

                 

                Since the wsdl has its own schema, when I add it to SoapUI it brings up the sequence from there (full of various tags). Where would I code the "sendReponse" and should that have any annotations? I ask because when I send the request, I do not get the string "hi" back. I want to be able to receive the message and do whatever I need with it. If you can guide me or link me to a tutorial, it would be greatly appreciated as I really want to learn about web services.

                • 5. Re: WSDL Override in Wildfly 10.0
                  nickarls

                  Well, lots of the stuff are implicit wrappers. If you are tasked with "reverse-engineering" a web service from a WSDL, you might want to try throwing it to

                   

                  https://docs.jboss.org/author/display/WFLY10/wsconsume

                   

                  and modify from there...

                  • 6. Re: WSDL Override in Wildfly 10.0
                    moic

                    Thank you very much! Everything is working good now.