[ 
https://issues.apache.org/jira/browse/AXIS2-2395?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Srinath Perera resolved AXIS2-2395.
-----------------------------------

    Resolution: Fixed

This is fixed in current code base, but issue was not closed. If you see the 
error again please let us know.

> AxisMessage.getSchema() returns null when schema element is found in an 
> imported schema
> ---------------------------------------------------------------------------------------
>
>                 Key: AXIS2-2395
>                 URL: https://issues.apache.org/jira/browse/AXIS2-2395
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 1.3
>         Environment: All
>            Reporter: Jeff Faath
>            Assignee: Deepal Jayasinghe
>            Priority: Blocker
>             Fix For: 1.3
>
>
> When calling getSchema() on an AxisMessage, 'null' is returned when the 
> schema element is found in an imported schema.  This is because the code does 
> not check imported schema.  I've devised a solution below which recursively 
> traverses any imported schema.  The original getSchema() method can be 
> replaced by the two methods below:
> public XmlSchemaElement getSchemaElement() {
>   AxisService service = (AxisService) getParent().getParent();
>     ArrayList schemas = service.getSchema();
>     for (int i = 0; i < schemas.size(); i++) {
>       XmlSchema schema = (XmlSchema) schemas.get(i);
>       return getSchemaElement(schema);
>     }
>     return null;
> }
> private XmlSchemaElement getSchemaElement(XmlSchema schema) {
>   XmlSchemaElement returnElement = null;
>   if (schema != null) {
>     if (schema.getItems() != null) {
>       Iterator schemaItems = schema.getItems().getIterator();
>       while (schemaItems.hasNext()) {
>         Object item = schemaItems.next();
>         if (item instanceof XmlSchemaElement) {
>           XmlSchemaElement xmlSchemaElement = (XmlSchemaElement) item;
>           if (xmlSchemaElement.getQName().equals(this.elementQname)) {
>             returnElement = xmlSchemaElement;
>           }
>         }
>        else if (item instanceof org.apache.ws.commons.schema.XmlSchemaImport) 
> {
>          returnElement = 
> getSchemaElement(((org.apache.ws.commons.schema.XmlSchemaImport)item).getSchema());
>        }
>        else if (item instanceof 
> org.apache.ws.commons.schema.XmlSchemaInclude) {
>          returnElement = 
> getSchemaElement(((org.apache.ws.commons.schema.XmlSchemaInclude)item).getSchema());
>        }
>        // We've found a matching element, no need to continue...
>        if (returnElement != null)
>          break;
>        }
>      }
>    }
>    return returnElement;
>  }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to