I'm trying to invoke Amazon's Web Services using Axis (for Java) 1.3. I've downloaded their WSDL, run WSDL2Java, and created a simple test case. When I run the test case, I keep running into the following exception as Axis parses the response from the server:

org.xml.sax.SAXException: Invalid element in ca.intelliware.amazonapi.Items - IsValid

I've used a proxy tool to capture the SOAP messages going back and forth, and based on my reading of the WSDL, the format is fine. Also, the error message suggests that the code is working with the wrong object type. Here's the snippet of the SOAP message that's significant:

<Items>
 <Request>
   <IsValid>True</IsValid>
 </Request>
 <Item>
 ...
 </Item>
</Items>

I would expect, therefore, that Axis should be working with a Request class, rather than an Items class.

I've tried some searches on this mailing list, and while there are some similar problems reported, I haven't been able to see anything that suggests the answer.

Here are some sanity checks I've tried:

1. The Request class looks properly created, and contains an isValid (String) member variable and appropriate getter/setter.

2. The Items class looks properly created and does not contain an isValid member variable (correctly, I believe).

3. The WSDL includes the following:

<xs:element name="Request">
 <xs:complexType>
   <xs:sequence>
     <xs:element name="IsValid" type="xs:string" minOccurs="0"/>
     <xs:element name="HelpRequest" type="tns:HelpRequest" minOccurs="0"/>
     ...
   </xs:sequence>
 </xs:complexType>
</xs:element>

4. I tried downloading and using Axis 1.2.1, but WSDL2Java didn't seem to generate versions of the client bindings that'd properly compile.

5. I've tracked the Exception down to these lines in BeanDeserializer.onStartChild(...):

       if (propDesc == null) {
           // No such field
           throw new SAXException(
                   Messages.getMessage("badElem00", javaType.getName(),
                                        localName));
       }

When I set a breakpoint there in my debugger, I find that the javaType of the BeanDeserializer is Items (not Request).
     Does anyone know what might cause this?

BC


Here's my SOAP request:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";
 xmlns:xsd="http://www.w3.org/2001/XMLSchema";
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
<soapenv:Body>
<ItemLookup xmlns="http://webservices.amazon.com/AWSECommerceService/2005-10-13";>
 <AWSAccessKeyId>$MY_ACCESS_KEY</AWSAccessKeyId>
 <Shared>
   <ItemId>0321278658</ItemId>
 </Shared>
 </ItemLookup>
</soapenv:Body>
</soapenv:Envelope>


Here's the response:


<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
 xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
<SOAP-ENV:Body>
<ItemLookupResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2005-10-13";>
<OperationRequest>
 <HTTPHeaders>
   <Header Name="UserAgent" Value="Axis/1.3"></Header>
 </HTTPHeaders>
 <RequestId>0SSYXJZE5DFVK083SPCW</RequestId>
 <Arguments>
   <Argument Name="Service" Value="AWSECommerceService"></Argument>
 </Arguments>
 <RequestProcessingTime>0.0151088237762451</RequestProcessingTime>
</OperationRequest>
<Items>
 <Request>
   <IsValid>True</IsValid>
 </Request>
 <Item>
   <ASIN>0321278658</ASIN>
   <DetailPageURL> ... very long url ... </DetailPageURL>
   <ItemAttributes>
     <Author>Kent Beck</Author>
     <Author>Cynthia Andres</Author>
     <ProductGroup>Book</ProductGroup>
<Title>Extreme Programming Explained : Embrace Change (2nd Edition)</Title>
   </ItemAttributes>
 </Item>
</Items>
</ItemLookupResponse>
</SOAP-ENV:Body></SOAP-ENV:Envelope>


Here's my stack trace:

org.xml.sax.SAXException: Invalid element in ca.intelliware.amazonapi.Items - IsValid at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:258) at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035) at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165) at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
   at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
   at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
   at org.apache.axis.client.Call.invoke(Call.java:2467)
   at org.apache.axis.client.Call.invoke(Call.java:2366)
   at org.apache.axis.client.Call.invoke(Call.java:1812)
at ca.intelliware.amazonapi.AWSECommerceServiceBindingStub.itemLookup(AWSECommerceServiceBindingStub.java:2380) at ca.intelliware.amazonapi.AWSECommerceServiceTest.testAWSECommerceService(AWSECommerceServiceTest.java:21)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:324)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at junit.framework.TestSuite.runTest(TestSuite.java:208)
   at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)



And my WSDL can be found here:

http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl




--
B.C. Holmes \u2625 http://www.bcholmes.org/ "Sel pa vante tèt li di li sale"
              -- Haitian proverb

Reply via email to