"llegal character in path at index" Error While Using wsimport from ant.
Hi,
I am getting the following error, while using wsimport from ant build script. you have the details below. I dont have a clue on this error.
Error :
wsimport:
[echo] Generating the client stubs
[wsimport] error: Unable to parse "HelloService_schema1.xsd" : Illegal character in path at index 25: file:/D:/Study/WebService Eclipse Project/examples/jaxws/helloservice/service/server/wsdl/HelloService.wsdl#types?schema1
[wsimport] line 0 of file:/D:/Study/WebService Eclipse Project/examples/jaxws/helloservice/service/server/wsdl/HelloService.wsdl#types?schema1
[wsimport] error: Unable to parse "HelloService_schema1.xsd" : Illegal character in path at index 25: file:/D:/Study/WebService Eclipse Project/examples/jaxws/helloservice/service/server/wsdl/HelloService.wsdl#types?schema1
[wsimport] line ? of file:/D:/Study/WebService Eclipse Project/examples/jaxws/helloservice/service/server/wsdl/HelloService.wsdl#types?schema1
[wsimport] error: Element "{http://endpoint.helloservice/}sayHello" not found.
Java WebService :
package helloservice.endpoint;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService()
public class Hello {
private String message = new String("Hello, ");
@WebMethod()
public String sayHello(String name) {
return message + name + ".";
}
}
Ant Build.xml
<project name="${project.name}" basedir="." default="ear">
<property file="WS_build.properties"/>
<target name="init">
<!-- Path Setting-->
<echo description="Setting the path for the project"/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="*.jar"/>
<fileset dir="${commonWSLib.dir}" includes="*.jar"/>
</path>
<!-- WSGen -->
<echo description="WSGEN Definition"/>
<taskdef name="wsgen" classname="com.sun.tools.ws.ant.WsGen">
<classpath>
<path refid="classpath"/>
</classpath>
</taskdef>
<!-- WS Import-->
<echo description="WSImport Definition" />
<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
<classpath>
<path refid="classpath"/>
</classpath>
</taskdef>
</target>
<target name="Compile" depends="init">
<echo description="Compiling the project"/>
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.dir}/classes"/>
<javac destdir="${build.dir}/classes" srcdir="${java.base}">
<classpath>
<path refid="classpath"/>
</classpath>
</javac>
<copy todir="${build.dir}/classes">
<fileset dir="${java.base}" excludes="**/*.java"/>
</copy>
</target>
<target name="wsgen" depends="Compile">
<echo message="Generating the wsdl file[${project.name}Service.wsdl]" />
<mkdir dir="${service.dir}"/>
<mkdir dir="${service.dir}/server"/>
<mkdir dir="${service.dir}/server/classes"/>
<mkdir dir="${service.dir}/server/src"/>
<mkdir dir="${service.dir}/server/wsdl"/>
<wsgen sei="${sei.class}" destdir="${service.dir}/server/classes" genwsdl="true"
sourcedestdir="${service.dir}/server/src" resourcedestdir="${service.dir}/server/wsdl">
<classpath>
<path refid="classpath" />
<pathelement location="${build.dir}/classes" />
</classpath>
</wsgen>
</target>
<target name="copy" depends="wsgen">
<echo message="Copying class and config files into ${web-inf.dir} folder" />
<copy todir="${web-inf.dir}">
<fileset dir="${build.dir}"/>
<fileset dir="${service.dir}/server" includes="**/*.class"/>
<fileset dir="." includes="${lib.dir}/*.jar"/>
</copy>
<copy todir="${web-inf.dir}/${lib.dir}">
<fileset dir="${commonWSLib.dir}" includes="*.jar"/>
</copy>
<copy todir="${web-inf.dir}">
<fileset dir="${web-inf.dir}" includes="**/*.xml"/>
</copy>
</target>
<!-- Create the WAR file -->
<target name="war" depends="copy">
<echo message="Creating the war file [${project.name}.war]" />
<mkdir dir="${dist.dir}"/>
<mkdir dir="${dist.dir}/server"/>
<war destfile="${dist.dir}/server/${project.name}.war" webxml="${web-inf.dir}/web.xml" basedir="${web.dir}"/>
</target>
<target name="wsimport" depends="war">
<echo message="Generating the client stubs" />
<mkdir dir="${service.dir}"/>
<mkdir dir="${service.dir}/client"/>
<mkdir dir="${service.dir}/client/classes"/>
<mkdir dir="${service.dir}/client/src"/>
<wsimport wsdl="${basedir}/${service.dir}/server/wsdl/${project.name}.wsdl"
destdir="${service.dir}/client/classes"
package="${wsimport.package}"
sourcedestdir="${service.dir}/client/src">
</wsimport>
</target>
<target name="clientjar" depends="wsimport">
<echo message="Creating the client jar file [${project.name}Client.jar] " />
<copy todir="${service.dir}/client/classes">
<fileset dir="${service.dir}/client/src"/>
</copy>
<mkdir dir="${dist.dir}/client"/>
<tstamp>
<format property="TODAY" pattern="yyyy-MM-dd hh:mm:ss" />
</tstamp>
<jar destfile="${dist.dir}/client/${project.name}Client.jar"
basedir="${service.dir}/client/classes">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Built-Date" value="${TODAY}"/>
<attribute name="Implementation-Version" value="${version}-b${build.number}"/>
</manifest>
</jar>
<mkdir dir="${dist.dir}/client"/>
</target>
<!-- JAR THE ENGINE -->
<target name="enginejar" depends="clientjar">
<echo message="Creating the engine jar file for local call [${project.name}.jar] " />
<!-- <copy todir="${build.dir}/classes">
<fileset dir="." includes="${config.dir}/hibernate.cfg.xml"/>
</copy> -->
<tstamp>
<format property="TODAY" pattern="yyyy-MM-dd hh:mm:ss" />
</tstamp>
<jar destfile="${dist.dir}/server/${project.name}.jar"
basedir="${build.dir}/classes">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Built-Date" value="${TODAY}"/>
<attribute name="Implementation-Version" value="${version}-b${build.number}"/>
</manifest>
</jar>
</target>
<!-- GENERATE EAR FOR THE ENGINE -->
<target name="ear" depends="enginejar" >
<echo message="Creating the ear file [${project.name}.ear]" />
<ear destfile="${dist.dir}/server/${project.name}.ear" appxml="META-INF/application.xml">
<fileset dir="${dist.dir}/server" includes="${project.name}.war"/>
</ear>
<antcall target="clean"></antcall>
</target>
<!-- CLEAN UP THE FOLDERS -->
<target name="clean">
<echo message="Cleaning up folders " />
<delete dir="${build.dir}"/>
<delete dir="${service.dir}"/>
<delete dir="${web-inf.dir}/classes"/>
<delete dir="${web-inf.dir}/lib"/>
<echo message="${project.name}.ear, ${project.name}.war, ${project.name}.jar and ${project.name}Client.jar is available in project's ${dist.dir} folder"/>
</target>
</project>
Generated wsdl(HelloService.wsdl) :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions targetNamespace="http://endpoint.helloservice/" name="HelloService" xmlns:tns="http://endpoint.helloservice/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<xsd:schema>
<xsd:import namespace="http://endpoint.helloservice/" schemaLocation="HelloService_schema1.xsd"/>
</xsd:schema>
</types>
<message name="sayHello">
<part name="parameters" element="tns:sayHello"/>
</message>
<message name="sayHelloResponse">
<part name="parameters" element="tns:sayHelloResponse"/>
</message>
<portType name="Hello">
<operation name="sayHello">
<input message="tns:sayHello"/>
<output message="tns:sayHelloResponse"/>
</operation>
</portType>
<binding name="HelloPortBinding" type="tns:Hello">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="sayHello">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="HelloService">
<port name="HelloPort" binding="tns:HelloPortBinding">
<soap:address location="REPLACE_WITH_ACTUAL_URL"/>
</port>
</service>
</definitions>
Generated : HelloService_schema1.xsd
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" targetNamespace="http://endpoint.helloservice/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="sayHello" type="ns1:sayHello" xmlns:ns1="http://endpoint.helloservice/"/>
<xs:complexType name="sayHello">
<xs:sequence>
<xs:element name="arg0" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:element name="sayHelloResponse" type="ns2:sayHelloResponse" xmlns:ns2="http://endpoint.helloservice/"/>
<xs:complexType name="sayHelloResponse">
<xs:sequence>
<xs:element name="return" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
If u need any other information let me know.