The current version of org.apache.wsif.schema.Parser does not work with 
WSDL4J1.5.1
-----------------------------------------------------------------------------------

         Key: WSIF-75
         URL: http://issues.apache.org/jira/browse/WSIF-75
     Project: Axis-WSIF
        Type: Bug
  Components: Basic Architecture  
    Versions: current (nightly), 2.0    
 Environment: Windows XP
    Reporter: Shantanu Sen


The current version of Parser does not work with WSDL4J1.5.1 since the child 
element of the types section of WSDL is 
of type javax.wsdl.extensions.schema.Schema - not the 
javax.wsdl.extensions.UnknownExtensibilityElement as it was
in the previous versions of WSDL4J.

The issue is in the getTypesSchemas method in the following line:

UnknownExtensibilityElement typesElement =     (UnknownExtensibilityElement) 
nextEl;

Since the typesElement is not an UnknownExtensibilityElement, it throws a 
ClassCastException at runtime.

The following code should fix this issue:

if(nextEl instanceof javax.wsdl.extensions.schema.Schema) {
    javax.wsdl.extensions.schema.Schema typesElement =  
(javax.wsdl.extensions.schema.Schema)nextEl;
     schemaEl = typesElement.getElement();
} else if (nextEl instanceof UnknownExtensibilityElement) {
     UnknownExtensibilityElement typesElement = (UnknownExtensibilityElement) 
nextEl;
      schemaEl = typesElement.getElement();
  } else {
     continue;
}

Here is the email trail that further describes the issue.

=========================
Shantanu Sen wrote:

>--- Aleksander Slominski <[EMAIL PROTECTED]> wrote:
>
>  
>
>>Shantanu Sen wrote:
>>
>>    
>>
>>>Sorry, I sent out the previou mail without finishing
>>>it...here is the complete one..
>>>
>>>--- Shantanu Sen <[EMAIL PROTECTED]> wrote:
>>>
>>> 
>>>
>>>      
>>>
>>>>Please see below for my response
>>>>
>>>>--- Aleksander Slominski <[EMAIL PROTECTED]>
>>>>wrote:
>>>>
>>>>   
>>>>
>>>>        
>>>>
>>>>>Shantanu Sen wrote:
>>>>>
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>What is the version of the wsdl4j.jar that is
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>>present
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>in the current CVS repo of WSIF? It says
>>>>>>wsdl4j-20030807.jar
>>>>>>
>>>>>>I tried to run with the wsdl4j-1.5.1 - but it
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>fails
>>>>   
>>>>
>>>>        
>>>>
>>>>>at
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>runtime although the WSIF build is fine. 
>>>>>>
>>>>>>The error is that when parsing a WSDL with the
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>>1.5.1
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>version the
>>>>>>Definition.getTypes().getExtensibilityElements()
>>>>>>returns a list of objects of type 
>>>>>>com.ibm.wsdl.extensions.schema.SchemaImpl.
>>>>>>
>>>>>>But when I invoke the
>>>>>>org.apache.wsif.schema.Parser.getAllSchemaTypes,
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>it
>>>>   
>>>>
>>>>        
>>>>
>>>>>>invokes the Parser.getTypesSchemas method, which
>>>>>>expects the list of extensibility elements
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>returned
>>>>   
>>>>
>>>>        
>>>>
>>>>>by
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>the above call to be of type
>>>>>>UnknownExtensibilityElement.
>>>>>>
>>>>>>Hence a ClassCastException is thrown.
>>>>>>
>>>>>>So, is there any plan to upgrade to the latest
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>>wsdl4j?
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>Does the latest wsdl4j give us any added benefit?
>>>>>>
>>>>>>I am curious - is the latest version correct in
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>>using
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>SchemaImpl as the type of the extensibility
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>>elements
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>rather than the UnknownExtensibilityElement?
>>>>>>
>>>>>>
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>>hi,
>>>>>
>>>>>i have  added a check to Parser.getTypesSchemas to
>>>>>skip non 
>>>>>UnknownExtensibilityElement and i have also
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>upgraded
>>>>   
>>>>
>>>>        
>>>>
>>>>>the WSIF in CVS to 
>>>>>use the 1.5.1 WSDL4J and i have updated AXIS to
>>>>>1.2.1 - that should help 
>>>>>to avoid jar linking problems.
>>>>>
>>>>>please try the version from CVS or nightly build
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>(in
>>>>   
>>>>
>>>>        
>>>>
>>>>>few hours) and send 
>>>>>email if you find other problems.
>>>>>
>>>>>thanks,
>>>>>
>>>>>alek
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>Alek,
>>>>
>>>>This will not work. The def.getTypes() returns the
>>>>types section of the document and that has typically
>>>>one child element - the schema. The code that you
>>>>added is skipping over that element since it is no
>>>>longer an UnknownExtensibilityElement, but a
>>>>com.ibm.wsdl.extensions.schema.SchemaImpl which is
>>>>an
>>>>ExtensibilityElement.
>>>>
>>>>Here is the part of the code that you added
>>>>===============================
>>>>Types types = def.getTypes();
>>>>if (types != null) {
>>>> Iterator extEleIt =
>>>>types.getExtensibilityElements().iterator();
>>>> while (extEleIt.hasNext()) {
>>>>   Object nextEl = extEleIt.next();
>>>>
>>>>   
>>>>
>>>>        
>>>>
>>>>>>>--- added by you in the current CVS tree
>>>>>>>         
>>>>>>>
>>>>>>>              
>>>>>>>
>>>>   if(!(nextEl instanceof
>>>>UnknownExtensibilityElement)) {
>>>>     continue;
>>>>   }
>>>>   
>>>>
>>>>        
>>>>
>>>>>>>-------------------
>>>>>>>         
>>>>>>>
>>>>>>>              
>>>>>>>
>>>> UnknownExtensibilityElement typesElement =
>>>>    (UnknownExtensibilityElement) nextEl;
>>>>
>>>>  Element schemaEl = typesElement.getElement();
>>>>....
>>>>=============
>>>>
>>>>I think it should test for an ExtensibilityElement
>>>>rather than UnkownExtensibilityElement since both
>>>>SchemaImpl and UnknownExtensibilityElement are a
>>>>type
>>>>of ExtensibilityElement.
>>>>
>>>>I thought that we could check for
>>>>ExtensibilityElement, but unfortunately it does not
>>>>have a getElement API.
>>>>
>>>>The other option is to check if the element (the
>>>>object nextEl above) is of type
>>>>javax.wsdl.extensions.schema.Schema and cast it to
>>>>that:
>>>>------------
>>>>Element schemaEl = null;
>>>>if(nextEl instanceof
>>>>javax.wsdl.extensions.schema.Schema) {
>>>> javax.wsdl.extensions.schema.Schema typesElement =
>>>>     (javax.wsdl.extensions.schema.Schema)nextEl;
>>>>  schemaEl = typesElement.getElement();
>>>>} else if (nextEl instanceof
>>>>UnknownExtensibilityElement)) {
>>>>   UnknownExtensibilityElement typesElement =
>>>>       (UnknownExtensibilityElement) nextEl;
>>>>  schemaEl = typesElement.getElement();
>>>>} else {
>>>>   
>>>>
>>>>        
>>>>
>>>  continue;
>>>}
>>>------------
>>>
>>>The issue is that once you add
>>>javax.wsdl.extensions.schema.Schema reference in the
>>>code, you can no longer build with the previous
>>>version of wsdl4j since I think this type was added
>>>later in WSDL4J.
>>>
>>>Please let me know what you think.
>>> 
>>>
>>>      
>>>
>>it starts to look really complicated - what do you think would eb the 
>>best solution that works for you assuming we do depend on the latest WSDL4J?
>>
>>thanks,
>>
>>alek
>>
>>-- 
>>The best way to predict the future is to invent it - Alan Kay
>>
>>
>>    
>>
>
>I think the code that I supplied should satsify all of us. 
>
>=====
>if(nextEl instanceof javax.wsdl.extensions.schema.Schema) {
>     javax.wsdl.extensions.schema.Schema typesElement =
>                          (javax.wsdl.extensions.schema.Schema)nextEl;
>      schemaEl = typesElement.getElement();
>} else if (nextEl instanceof UnknownExtensibilityElement)) {
>    UnknownExtensibilityElement typesElement = (UnknownExtensibilityElement) 
> nextEl;
>    schemaEl = typesElement.getElement();
>} else {
>    continue;
>}
>============
>
>Note the following about this code:
>
>1. It takes care of the possibility of a child element of types to be of type
>UnknownExtensibilityElement
>2. It takes care of the current scenario with WSDL4J1.5 - where the type is of
>javax.wsdl.extensions.schema.Schema.
>3. It ignores any other type - so if the WSDL contains other types in the 
>types section
>then there will not be any classcastexception.
>
>This satisfies all the cases that I can think of. If you think of anything 
>that I am
>missing please let me know. Else, I feel this should work.
>
>The only drawback is that we cannot compile against a previous version of 
>WSDL4J. But I
>think that should be acceptable - there is no requirement for it to be backward
>compatible right?
>
>  
>
Shantanu,

i will try to apply this patch to SVN and see what happens. could you open JIRA 
issue for 
it?

thanks,

alek
============

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

Reply via email to