dev@jax-ws-commons.java.net

jaxws-maven-plugin wsimport is not working with wsdlUrl

From: Cristiano Gavião <cvgaviao_at_gmail.com>
Date: Tue, 24 Nov 2009 09:46:41 -0300
Hi,

I've created a simple example to test both wsimport and wsgen. wsgen works well, but wsimport is not working when I try to run it with wsdlUrl. It works running if I set up for reading from the wdsls generated by wsgen.
Could someone tell me if I did something wrong?

First I've created the services using wsgen.

@WebService(targetNamespace = "http://drysoftware.com.br", name = "IHello")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL)
public interface IHello {

    @WebMethod
    public String sayHello(@WebParam(name = "message") String param);

    @WebMethod
    public String sayHello2(@WebParam(name = "message")String param);

}

@WebService(endpointInterface="com.example.maven.jaxws.helloservice.IHello")
public class Hello implements IHello{

    @Override
    public String sayHello(String message) {
        return "Hello " + message;
    }

    @Override   
    public String sayHello2( String param) {
        return "Hello2 " + param;
    }
}

I used this configuration to deploy the service on the jetty server:
sun-jaxws.xml:
<?xml version="1.0" encoding="UTF-8"?>
<endpoints xmlns='http://java.sun.com/xml/ns/jax-ws/ri/runtime' version='2.0'>
    <endpoint
        name='com.example.maven.jaxws.helloservice.IHello'
        implementation='com.example.maven.jaxws.helloservice.Hello'
        url-pattern='/HelloService'/>
</endpoints>

web.xml
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
            http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <listener>
        <listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
    </listener>
    <servlet>
        <description>JAX-WS endpoint - helloService</description>
        <display-name>helloService</display-name>
        <servlet-name>webServiceServlet</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>webServiceServlet</servlet-name>
        <url-pattern>/HelloService</url-pattern>
    </servlet-mapping>
</web-app>

That is the pom for wsgen:
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>1.12</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>wsgen</goal>
                        </goals>
                        <configuration>
                            <sei>com.example.maven.jaxws.helloservice.Hello</sei>
                            <!--for demo purpose only, the webapp does not-->
                            <!--need the generated wsdl files-->
                            <genWsdl>true</genWsdl>
                            <keep>true</keep>   
                            <verbose>true</verbose>               
                            <sourceDestDir>${project.build.directory}/generated-sources/wsgen/java</sourceDestDir>
                            <resourceDestDir>${project.build.directory}/generated-sources/wsgen/resources</resourceDestDir>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

I've deployed the webservice and tested it using a browser and everything seams to works well. So I tried to run wsimport with this pom:

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>1.12</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                            <sourceDestDir>${project.build.directory}/generated-sources/wsimport/java</sourceDestDir>
                            <staleFile>${project.build.directory}/generated-sources/wsimport/stale/.staleFlag</staleFile>
                            <!--

                                <wsdlDirectory>${basedir}/src/main/resources/wsdl</wsdlDirectory>
                                <wsdlFiles> <wsdlFile>HelloService.wsdl</wsdlFile> </wsdlFiles>
                            -->
                            <wsdlUrls>
                                <wsdlUrl>http://localhost:8080/helloservice/HelloService?wsdl</wsdlUrl>
                            </wsdlUrls>

                            <packageName>com.example.maven.jaxws.helloclient</packageName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Wsimport do not created any class, only the folders and do not give me any error message.
Here is a part of the wsimport debug info. It seams that wsimport is trying to parse the jsp and not the wsdl file:

[INFO] jaxws:wsimport args: [-s, C:\Documents and Settings\cgaviao\Meus documentos\Tutoriais\jaxws-maven-sample\helloclient\target\generated-sources\wsimport\java, -d, C:\Documents and Settings\cgaviao\Meus documentos\Tutoriais\jaxws-maven-sample\helloclient\target\classes, -p, com.example.maven.jaxws.helloclient, -Xnocompile, http://localhost:8080/helloservice/HelloService?wsdl]
parsing WSDL...


[WARNING] s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'Web Services'.
  line 3 of http://localhost:8080/helloservice/HelloService?null

[WARNING] s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'Web Services'.
  line 6 of http://localhost:8080/helloservice/HelloService?null

[WARNING] s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'Endpoint
'.
  line 11 of http://localhost:8080/helloservice/HelloService?null

[WARNING] s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'Information
'.
  line 14 of http://localhost:8080/helloservice/HelloService?null

[WARNING] s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'Service Name:'.
  line 18 of http://localhost:8080/helloservice/HelloService?null

[WARNING] s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw '{http://helloservice.jaxws.maven.example.com/}HelloService'.
  line 18 of http://localhost:8080/helloservice/HelloService?null

[WARNING] s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'Port Name:'.
  line 18 of http://localhost:8080/helloservice/HelloService?null

[WARNING] s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw '{http://helloservice.jaxws.maven.example.com/}HelloPort'.
  line 18 of http://localhost:8080/helloservice/HelloService?null

[WARNING] s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'Address:'.
  line 21 of http://localhost:8080/helloservice/HelloService?null

[WARNING] s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'http://localhost:8080/helloservice/HelloService'.
  line 21 of http://localhost:8080/helloservice/HelloService?null

[WARNING] s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'WSDL:'.
  line 21 of http://localhost:8080/helloservice/HelloService?null

[WARNING] s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'http://localhost:8080/helloservice/HelloService?wsdl'.
  line 21 of http://localhost:8080/helloservice/HelloService?null

[WARNING] s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'Implementation class:'.
  line 21 of http://localhost:8080/helloservice/HelloService?null

[WARNING] s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'com.example.maven.jaxws.helloservice.Hello'.
  line 21 of http://localhost:8080/helloservice/HelloService?null

[WARNING] s4s-elt-schema-ns: The namespace of element 'html' must be from the schema namespace, 'http://www.w3.org/2001/XMLSchema'.
  line 1 of http://localhost:8080/helloservice/HelloService?null

[WARNING] s4s-elt-invalid: Element 'html' is not a valid element in a schema document.
  line 1 of http://localhost:8080/helloservice/HelloService?null

[WARNING] src-import.2: The root element of document 'http://localhost:8080/helloservice/HelloService?null' has to have the namespace name 'http://www.w3.org/2001/XMLSchema' and the local name 'schema'.
  line 1 of http://localhost:8080/helloservice/HelloService?null

[ERROR] Unexpected <html> appears at line 1 column 7
  line 1 of http://localhost:8080/helloservice/HelloService?null