wsgen ClassCastException from JPrimitiveType to JClass
------------------------------------------------------

                 Key: XFIRE-806
                 URL: http://jira.codehaus.org/browse/XFIRE-806
             Project: XFire
          Issue Type: Bug
          Components: Generator
    Affects Versions: 1.2.3
         Environment: Windows, Ant
            Reporter: Geert Engels
         Assigned To: Dan Diephouse



Using Ant wsgen task from xfire 1.2.3 against WSDL from 
https://adwords.google.com/api/adwords/v8/CampaignService?wsdl I get:

    [wsgen] 15-Dec-2006 09:20:04 org.codehaus.xfire.gen.Wsdl11Generator generate
    [wsgen] INFO: Generating code for WSDL at 
file:/c:/work/workspace/bcp/src/etc/wsdl/ggl/CampaignService.wsdl with a ba
e URI of file:/c:/work/workspace/bcp/src/etc/wsdl/ggl/CampaignService.wsdl
    [wsgen] 15-Dec-2006 09:20:04 
org.codehaus.xfire.gen.jsr181.AbstractServiceGenerator generate
    [wsgen] INFO: Creating class com.teracode.bcp.api.ggl.CampaignInterface

BUILD FAILED
C:\work\workspace\bcp\build\build.xml:72: 
org.codehaus.xfire.gen.GenerationException: Could not find holder type.

This seems to be the same as question posted on Nov 2nd here 
http://www.mail-archive.com/[email protected]/msg01259.html to which 
there never was a reply.

Running the Ant task through a debugger, I can intercept an embedded 
ClassCastException, which originates at line 
org.codehaus.xfire.gen.jsr181.AbstractServiceGenerator.java:252.

The code there is as follows:

protected JType getHolderType(GenerationContext context,MessagePartInfo part)
        throws GenerationException
    {
        JType genericType = context.getSchemaGenerator().getType(context, 
part.getName(), part.getSchemaType().getSchemaType());
       
        try {
            JClass holder = context.getCodeModel().ref("javax.xml.ws.Holder");
            holder = holder.narrow((JClass) genericType); /* THIS IS WHERE THE 
CLASSCASTEXCEPTION OCCURS */
            return holder;
        } catch (Exception e) {
            throw new GenerationException("Could not find holder type.", e);
        }
    }


The MessagePartInfo, when the ClassCast is thrown, contains a schemaType which 
stringifies to "org.codehaus.xfire.aegis.type.basic.ObjectType[class=<null>,
QName={https://adwords.google.com/api/adwords/v8}responseTime]";.

The ClassCastException is from JPrimitiveType to JClass.

Anybody know how to get Xfire wsgen to work with this WSDL? All others from 
WSDLs from Google AdWords API, not only this service but all others, and not 
only v8 but v7 and v6 as well, fail in the same way.

It's easy to reproduce, using a testcase as per below:

import junit.framework.TestCase;

public class WsGenTest extends TestCase {
        
        public void testIt() throws Exception {
                WsGenTask task = new WsGenTask();
                task.setOutputDirectory("C:/EXT");
                
task.setWsdl("https://adwords.google.com/api/adwords/v8/CampaignService?wsdl";);
                task.setPackage("blah");
                task.setOverwrite(true);
                task.setGenerateServerStubs(false);
                //task.setCaseSensitive(false);
                //task.setDefaultexcludes(false);
                try {
                        task.execute();
                } catch( Throwable t ) {
                        t.printStackTrace();
                        fail(t.toString());
                }
        }

}




-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to