[WsGen] Anonymous types in wsdl:message cause NPE
-------------------------------------------------

         Key: XFIRE-315
         URL: http://jira.codehaus.org/browse/XFIRE-315
     Project: XFire
        Type: Bug

  Components: Generator  
    Versions: 1.0    
    Reporter: Kenny MacLeod
 Assigned to: Dan Diephouse 
    Priority: Critical


When you try to use Wsdl11Generator (e.g,. from WsGenTask)  to generate WSDL 
bindings from a WSDL file which contains Messages with anonymous schema types, 
you get a NullPointerException from AbstractServiceGenerator.

Take the following WSDL fragment:

<wsdl:message name="MyMessage">
    <wsdl:part name="parameters" element="tns:MyResponse" />
</wsdl:message>

  <wsdl:types>
    <s:schema elementFormDefault="qualified" 
targetNamespace="http://tempuri.org/";>
      <s:element name="MyResponse">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="request" 
type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
    </s:schema>
  </wsdl:types>

If you look at WSDLServiceBuilder.createMessagePart(), you see the following 
logic:

        MessagePartInfo part = info.addMessagePart(element.getQName(), 
XmlSchemaElement.class);

        SchemaType st = null;
        if (element.getRefName() != null)
        {
            st = getBindingProvider().getSchemaType(element.getRefName(), 
service);
        }
        else if (element.getSchemaTypeName() != null)
        {
            st = 
getBindingProvider().getSchemaType(element.getSchemaTypeName(), service);
        }
        
        part.setSchemaType(st);


It appears that this code will only work for Messages with non-anonymous 
element types.  However, it looks as though it would be trivial to check 
whether the element has an anonymous type by adding another elese-if clause:

        else if (element.getSchemaType() != null)
        {
            st = element.getSchemaType();
        }


-- 
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

Reply via email to