• Post Reply Bookmark Topic Watch Topic
  • New Topic

Complex type generating "invalid element" error with Axis 1.3

 
Don Markham
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Axis 1.3 and document binding style/literal wrapped use when generating XML code, which is required by the web service. I used WSDL2Java to create the Java stubs.

The XML that is sent to the web service is correct. The XML that is returned generates an "invalid element" error on the first field of an array. More specifically, an address array is returned and the error occurs on the first of seven fields (all string) of the array.

I have seen references to this issue and some suggestions as to how the problems can be addressed. Nothing is specific enough to help me get past the problem.

The error is:
- Exception:
org.xml.sax.SAXException: Invalid element in [namespace]._OffersResponse - Predir
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 [namespace].OffersServiceSoapStub.queryOffers(OffersServiceSoapStub.java:526)
at [namespace].TestClient.main(TestClient.java:119)
org.xml.sax.SAXException: Invalid element in [namespace]._OffersResponse - Predir
 
Enrico Giurin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I had the same problem, especially when I used array of complex type.
I had this error when I ran client axis.
org.xml.sax.SAXException: Invalid element in CTDirectoryNumber - item

I found solution ,thanks to Marco Marchi ,at this problem modifying wsdl, that is, cut off name attribute from definition of my array of complex type.
Here there is section of wsdl previous, when I had error.

<complexType name="ArrayOf_seb_CTDirectoryNumber">
<sequence>
<element name="item" type="seb:CTDirectoryNumber" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
</complexType>

After I removed attribute name (name="item") and section was this:

<complexType name="ArrayOf_seb_CTDirectoryNumber">
<sequence>
<element type="seb:CTDirectoryNumber" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
</complexType>

With this wsdl I made java code using axis wsdl2java and now it works properly.
Hope this tip could save your valueble time.

Enrico Giurin
SCJP, SCWCD, SCBCD, SCDJWS (coming soon).
 
Vlad Dubrovski
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Axis 1.3 and am trying to skip parsing of fields on the client,
the fields which server already sends but client doesn't know yet (no such field in WSDL)

I've tried your trick (add unnamed field), but it did not help

Wsdl2Java generated:

elemField.setFieldName("_null");
elemField.setXmlName(new javax.xml.namespace.QName("urn:vds", "null"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
elemField.setMaxOccursUnbounded(true);
typeDesc.addFieldDesc(elemField);
elemField = new org.apache.axis.description.ElementDesc();

and now it just thinks that tag "_null" is also valid.

I'd like to ignore unknown tags supplied to me from the server.
Any ideas?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!