views:

287

answers:

3

HI guys!

I try to call Axis2 WSDL2JAVA in my ant file to create a WSDL client. But it's broken because I have whitespaces in my path (I'm on Windows...). This is my ant

<property name="wsdl.file" location="C:\path with whitespaces\project\subdir\my.wsdl"/>
...
<target name="generate.client" depends="Clean.Client">
    <java  classname="org.apache.axis2.wsdl.WSDL2Java">
        <arg value="-uri" />
        <arg file="${wsdl.file}"/>
        <arg value="-u"/>
        <arg value="-p"/>
        <arg value="my.package.declaration"/>
        <arg value="-S"/>
        <arg value="src/test"/>
        ...
        <classpath refid="axis2.classpath"/>
    </java>
</target>

When I try to run it, I get this errors:

[java] Caused by: java.net.URISyntaxException: Illegal character in path at index 18: file:/C:/path with whitespaces/project/subdir/my.wsdl
 [java]     at java.net.URI$Parser.fail(URI.java:2809)
 [java]     at java.net.URI$Parser.checkChars(URI.java:2982)
 [java]     at java.net.URI$Parser.parseHierarchical(URI.java:3066)
 [java]     at java.net.URI$Parser.parse(URI.java:3014)
 [java]     at java.net.URI.<init>(URI.java:578)
 [java]     at org.apache.ws.commons.schema.resolver.DefaultURIResolver.resolveEntity(DefaultURIResolver.java:57)
 [java]     ... 39 more

I tried to add & quot; to my property, but it doesn't work and gives me a doubled path then. I also tried to change the nested arg value= to arg line= but it's the same.

Is this really a but that stops me from building from a directory with whitespaces? I can't believe it's still happening these days... :-(

Update I can't move the project to get rid of the whitespaces.

A: 

The simple solution is to get rid of those pesky whitespaces. Trust me, you'll be glad you did.

Stephen C
Moving the project isn't an option... :-/
cringe
+2  A: 

In an URI the blanks must be escaped as %20

Maurice Perry
Can I do it with standard ant or do I have to use the ContribTask UrlEncode?
cringe
Oh, and btw. WSDL2JAVA wants an URI or a path, so I think I don't need to URLencode it: [java] Usage: WSDL2Java [options] -uri <url or path> : A url or path to a WSDL
cringe
Your code is passing the file as a path. If your are not using the property anywhere else, you can set it to a syntactically correct URI. If you want the property to be a file path however, you will need to use the ContribTask UrlEncode.
Maurice Perry
I was using the project ${basedir}. For now I hardcoded the project path with shortcuts as described by **akf** in a comment. I think I have to use UrlEncode to get rid of the hardcoded path. :-/ Thanks
cringe
+1  A: 

Since you are on Windows, you have the option to use shortnames for your directories. You use the dir /x command on your directories to find the shortnames. For example, dir /x c:\ will list the files and directories on your C:\, including the root of "path with whitespaces", without the whitespaces.

A common shortname that you will find helpful is that for "Program Files", which generally resolves to 'PROGRA~1'.

In your example, the path might turn out to:

C:\pat~1\project\subdir\my.wsdl

However, it would be best, as mentioned above, to test the path out by using the dir command (both with the /x to get the shortname, and then after again, to test the use of the shortname.

akf
I'm not using hardcoded directory names, I'm using the project $basedir which is set as ".".
cringe
I used the short name as a hardcoded value now, but I really have to get rid of it. So I think I'll get the ContribTask UrlEncode in my ant. Thanks
cringe