WSIF handling of arrays

Alan Su <[email protected]> Mon, 3 Apr 2006 12:57:40 -0400
Newsgroups gmane.comp.apache.webservices.wsif.user
Message-ID <[email protected]>
Hi,

I'm trying to use WSIF 2.0 to dynamically access a web service  
essentially generated via the Globus toolkit.  In particular, the web  
service operation I want to access has an input message that is  
defined to have a single part; this is the appropriate exerpt from  
the corresponding WSDL document:

   <message name="plot_2DInputMessage">
     <part element="tns:plot_2D" name="parameters"/>
   </message>

where the plot_2D element is defined here:

   <xsd:element name="plot_2D">
     <xsd:complexType>
       <xsd:sequence>
         <xsd:element maxOccurs="1" minOccurs="1" name="lsids">
           <xsd:complexType>
             <xsd:complexContent>
               <xsd:restriction base="soapenc:Array">
                 <xsd:attribute ref="soapenc:arrayType"  
wsdl:arrayType="ns0:LsidType[]"/>
               </xsd:restriction>
             </xsd:complexContent>
           </xsd:complexType>
         </xsd:element>
       </xsd:sequence>
     </xsd:complexType>
   </xsd:element>

in turn LsidType, the base type of the array in the input message is  
defined fairly simply:

   <xs:complexType name="LsidType">
     <xs:annotation>
       <xs:documentation>A life sciences identifier</xs:documentation>
     </xs:annotation>
     <xs:sequence>
       <xs:element name="value" type="xs:string">
         <xs:annotation>
           <xs:documentation>A life sciences identifier</ 
xs:documentation>
         </xs:annotation>
       </xs:element>
     </xs:sequence>
   </xs:complexType>

Yes, needlessly complicated, perhaps (i.e., creating a complex type  
to wrap a string), but that is what i have to work with.  so, i use  
WSDL2Java to generate the necessary stub files, which gives me what i  
suppose i need to access this service programmatically: a bean class  
LsidType with a custom deserializer, and a stub class _plot_2D that  
accepts an array of LsidType objects via a setLsids method.  This  
looks promising to me...(I also have the stub and base classes for  
the output message, but i'm omitting them because i don't think  
they're part of the problem.)

So using the localjava sample from the WSIF distribution as a mold, I

  - instantiate a WSIFServiceFactory and then a WSIFService for the  
service described in the WSDL document;
  - call the WSIFService.mapType() method on each of the base types  
then the enclosing message types (is all this necessary?) for both  
the input and output messages of the targeted operation;
  - instantiate WSIFPort and WSIFOperation objects for the operation  
that uses the input message described above;
  - create a hard-coded array of the LsidType objects from values  
that I've verified should work (via a program that uses the non- 
dynamic stub approach);
  - put that array in a WSIFMessage object created via the  
WSIFOperation.createInputMessage() method; and
  - attempt to invoke the operation via the  
WSIFOperation.executeRequestResponseOperation() method.

this call raises a org.apache.wsif.WSIFException:

   org.apache.wsif.WSIFException: exception on AXIS invoke:  
java.lang.ArrayStoreException; nested exception is:
         java.lang.ArrayStoreException

Can anyone spot an obvious error in how i'm using WSIF to accomplish  
this?  Does anyone have any ideas what might cause this behavior?   
i'm wondering if the schema (esp. the use of an array of what is  
technically a complex type) might be the root cause of this problem.   
if so, i would greatly appreciate a pointer to a reference that  
describes the constraints of the XML schemas that may be used with  
WSIF.  in case it helps, i printed out the stack trace on this  
exception and included it as an attachment at the bottom of this  
message.  anyway, i'm starting to believe that I need to bite the  
bullet and manage the message construction at a lower level (using  
the AXIS Call interface?) to make this work...but I'm still hoping  
that I'm wrong and that someone will show me where i've gone astray  
in using WSIF!

Thanks in advance for any ideas, clues, or suggestions on alternate  
approaches,

-alan
stacktrace.txt (text/plain, 2.6 KB)
org.apache.wsif.WSIFException: exception on AXIS invoke: java.lang.ArrayStoreException; nested exception is: 
        java.lang.ArrayStoreException
        at org.apache.wsif.providers.soap.apacheaxis.WSIFOperation_ApacheAxis.invokeAXISDocStyle(Unknown Source)
        at org.apache.wsif.providers.soap.apacheaxis.WSIFOperation_ApacheAxis.invokeRequestResponseOperation(Unknown Source)
        at org.apache.wsif.providers.soap.apacheaxis.WSIFOperation_ApacheAxis.executeRequestResponseOperation(Unknown Source)
        at CGInt.testPlot2D(CGInt.java:378)
        at CGInt.main(CGInt.java:602)
Caused by: java.lang.ArrayStoreException
        at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:260)
        at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:169)
        at org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1083)
        at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1712)
        at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
        at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
        at org.apache.crimson.parser.Parser2.content(Parser2.java:1963)
        at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691)
        at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667)
        at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
        at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)        at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
        at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:252)
        at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
        at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
        at org.globus.ogsa.handlers.RoutingHandler.getRouterHeader(RoutingHandler.java:31)
        at org.globus.ogsa.handlers.RoutingResponseHandler.invoke(RoutingResponseHandler.java:26)
        at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
        at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)
        at org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)
        at org.apache.axis.client.AxisClient.invoke(AxisClient.java:193)
        at org.apache.axis.client.Call.invokeEngine(Call.java:2564)
        at org.apache.axis.client.Call.invoke(Call.java:2553)
        at org.apache.axis.client.Call.invoke(Call.java:2248)
        at org.apache.axis.client.Call.invoke(Call.java:2171)
        at org.apache.axis.client.Call.invoke(Call.java:1691)
        ... 5 more