package org.codehaus.xfire.gen;

import java.net.URL;
import java.net.URLClassLoader;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.MatchingTask;
import org.codehaus.xfire.gen.jsr181.Jsr181Profile;

public class WsGenTask extends MatchingTask
{
    private String wsdl;
    private String outputDirectory;
    private String _package;
    private String profile = Jsr181Profile.class.getName();
    private String binding;

    public void execute()
        throws BuildException
    {

        super.execute();
        
        // Ugly fix for XFIRE-245: wsgen can't find XMLInputFactory
        ClassLoader originalCL = Thread.currentThread().getContextClassLoader();
    	Thread.currentThread().setContextClassLoader(Wsdl11Generator.class.getClassLoader());
    	
        Wsdl11Generator generator = new Wsdl11Generator();
        generator.setDestinationPackage(_package);
        generator.setOutputDirectory(outputDirectory);
        generator.setWsdl(wsdl);
        if (binding != null) generator.setBinding(binding);
        if (profile != null) generator.setProfile(profile);
        
        try
        {
            generator.generate();
        }
        catch (Exception e)
        {
            throw new BuildException(e);
        }
        
    	Thread.currentThread().setContextClassLoader(originalCL);
    }

    public String getPackage()
    {
        return _package;
    }

    public void setPackage(String _package)
    {
        this._package = _package;
    }

    public String getBinding()
    {
        return binding;
    }

    public void setBinding(String binding)
    {
        this.binding = binding;
    }

    public String getOutputDirectory()
    {
        return outputDirectory;
    }

    public void setOutputDirectory(String outputDirectory)
    {
        this.outputDirectory = outputDirectory;
    }

    public String getProfile()
    {
        return profile;
    }

    public void setProfile(String profile)
    {
        this.profile = profile;
    }

    public String getWsdl()
    {
        return wsdl;
    }

    public void setWsdl(String wsdl)
    {
        this.wsdl = wsdl;
    }
}
@@ -452,17 +452,49 @@
 inding;%0A
+    private String baseURI;%0A    
 %0A
-
     publ
@@ -1026,16 +1026,64 @@
 (wsdl);%0A
+        generator.setBaseURI(baseURI);%0A        %0A
         
@@ -1363,24 +1363,24 @@
  %7D%0A        %0A
-
     %09Thread.
@@ -1429,32 +1429,188 @@
 inalCL);%0A    %7D%0A%0A
+    public String getBaseURI()%0A    %7B%0A        return baseURI;%0A    %7D%0A%0A    public void setBaseURI(String baseURI)%0A    %7B%0A        this.baseURI = baseURI;%0A    %7D%0A%0A
     public Strin

Add a BaseURI property to resolve imports relative to.