2 Replies Latest reply on Sep 10, 2009 3:28 PM by rsobchak

    having trouble specifying namespace

    rsobchak Newbie

      I have a web service on JBoss-4.2.3.GA using JBossWS-native-3.0.3.GA. The web service is currently not specifying a namespace.
      I am having problems specifying the namespace.

      The interface is defined as follows

      @WebService(name = "MyWebService")
      @SOAPBinding(style = Style.DOCUMENT, use=Use.LITERAL, parameterStyle=ParameterStyle.WRAPPED)
      
      public interface MyWebService
      {
       public void myMethod(String param1);
      }
      


      The implementation is defined as follows
      @WebService(serviceName = "MyEndpointService",
       portName = "MyEndpointPort",
       endpointInterface = "com.myCompany.MyWebService")
      @WebContext(contextRoot = "/myCompany", urlPattern = "/myWebService")
      @Stateless
      
      public class myEJB
      {
       public void myMethod(String param1)
       {
       }
      }
      


      This deploys and creates a single WSDL in the default (i.e. package) namespace.


      When I attempt to specify the targetNamespace, the WSDL is broken into two with one importing the other.

      The code with the namespace is as follows

      @WebService(name = "MyWebService",
       targetNamespace="http://com.myCompany")
      @SOAPBinding(style = Style.DOCUMENT, use=Use.LITERAL, parameterStyle=ParameterStyle.WRAPPED)
      
      public interface MyWebService
      {
       public void myMethod(String param1);
      }
      


      @WebService(serviceName = "MyEndpointService",
       portName = "MyEndpointPort",
       targetNamespace="http://com.myCompany"
       endpointInterface = "com.myCompany.MyWebService")
      @WebContext(contextRoot = "/myCompany", urlPattern = "/myWebService")
      @Stateless
      
      public class myEJB
      {
       public void myMethod(String param1)
       {
       }
      }
      



      The resulting WSDL looks like this
      <definitions name="MyEndpointService" targetNamespace="http://com.myCompany/" xmlns="http://schemas.xmlsoap.org/wsdl/"
       xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:ns1="http://default.package/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
       xmlns:tns="http://com.myCompany/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
       <import location="http://hostname:8080/myCompany/myWebService?wsdl&resource=MyWebService_PortType12338.wsdl" namespace="http://default.package/" />
       <service name="MyEndpointService">
       <port binding="ns1:MyWebServiceBinding" name="MyEndpointPort">
       <soap:address location="http://hostname:8080/myCompany/myWebService" />
       </port>
       </service>
      </definitions>
      


      According to the java doc on WebService annotation specifying the same targetNamespace on the interface and implemenation would result in one WSDL
      in the same namespace. Am I missing something?



        • 1. Re: having trouble specifying namespace
          rsobchak Newbie

          Update:

          If I use the ant task wsprovide to build the wsdl from the code the wsdl is created with the correct namespace.

          What is different between having JBoss create the wsdl at run-time vs using the wsprovide task to create the wsdl at compile-time?

          • 2. Re: having trouble specifying namespace
            rsobchak Newbie

            Update:

            I removed the SEI so now the web service looks like this

            @WebService(serviceName = "MyEndpointService",
             portName = "MyEndpointPort",
             targetNamespace="http://com.myCompany")
            @WebContext(contextRoot = "/myCompany", urlPattern = "/myWebService")
            @Stateless
            
            public class MyEJB
            {
             public void myMethod(String param1)
             {
             }
            }
            


            When this is deployed with JBoss creating the WSDL, the namespace in the WSDL is "http://com.myCompany" with no import of another WSDL.

            What am I doing wrong when specifying the SEI and its targetNamespace that causes the WSDL to import another WSDL with the default package as the namespace (and not the targetNamespace)?