Amila, Any updates on this one ? Please advice.
I used Axis2 1.4.1 release. Many Thanks, Nateshan On Wed, Dec 31, 2008 at 8:51 AM, Nateshan Soundarapandian < nates...@gmail.com> wrote: > Dear Amila, > > Thanks for the response. > > I tried what you mentioned. I till get the same exception. Here are the > artifacts: > > 1. Test Class: > package com.ihg.ws.cxf.servlets; > > import java.io.ByteArrayInputStream; > > import javax.xml.stream.XMLStreamReader; > > import org.apache.axiom.om.util.StAXUtils; > import org.opentravel.www.ota._2003._05.ContactNumbers_type0; > > public class ContactNumbersTest { > > public static void main(String[] args) { > String newString = "<ContactNumbers xmlns=\" > http://www.opentravel.org/OTA/2003/05\<http://www.opentravel.org/OTA/2003/05%5C> > ">\n" > + "<ContactNumber PhoneNumber=\"1-305-4469000\" > PhoneTechType=\"1\" PhoneUseType=\"5\"/>\n" > + "<ContactNumber PhoneNumber=\"1-305-4471189\" > PhoneTechType=\"3\" PhoneUseType=\"5\"/>\n" > + "</ContactNumbers>"; > try { > XMLStreamReader xmlReader = StAXUtils > .createXMLStreamReader(new > ByteArrayInputStream(newString > .getBytes())); > ContactNumbers_type0 result = ContactNumbers_type0.Factory > .parse(xmlReader); > } catch (Exception e) { > e.printStackTrace(); > } > } > } > > > EXCEPTION: > java.lang.Exception: org.apache.axis2.databinding.ADBException: Unexpected > subelement ContactNumber > at > org.opentravel.www.ota._2003._05.ContactNumbers_type0$Factory.parse(ContactNumbers_type0.java:582) > at > com.ihg.ws.cxf.servlets.ContactNumbersTest.main(ContactNumbersTest.java:22) > Caused by: org.apache.axis2.databinding.ADBException: Unexpected subelement > ContactNumber > at > org.opentravel.www.ota._2003._05.ContactNumbers_type0$Factory.parse(ContactNumbers_type0.java:578) > ... 1 more > > > Generated Factory.parse method in Class ContactNumbers_type0 (Please note > the section marked between >>>>>>>>>> and <<<<<<<<<<<<, At this point Both > reader.isEndElement() and reader.isStartElement() are true): > > -------------------------------------------------------------------------------------------------------------- > public static ContactNumbers_type0 parse( > javax.xml.stream.XMLStreamReader reader) > throws java.lang.Exception { > ContactNumbers_type0 object = new ContactNumbers_type0(); > > int event; > java.lang.String nillableValue = null; > java.lang.String prefix = ""; > java.lang.String namespaceuri = ""; > try { > > while (!reader.isStartElement() && !reader.isEndElement()) > reader.next(); > > if (reader.getAttributeValue( > "http://www.w3.org/2001/XMLSchema-instance", > "type") != null) { > java.lang.String fullTypeName = reader > .getAttributeValue( > " > http://www.w3.org/2001/XMLSchema-instance", > "type"); > if (fullTypeName != null) { > java.lang.String nsPrefix = null; > if (fullTypeName.indexOf(":") > -1) { > nsPrefix = fullTypeName.substring(0, > fullTypeName > .indexOf(":")); > } > nsPrefix = nsPrefix == null ? "" : nsPrefix; > > java.lang.String type = fullTypeName > .substring(fullTypeName.indexOf(":") + 1); > > if (!"ContactNumbers_type0".equals(type)) { > // find namespace for the prefix > java.lang.String nsUri = reader > .getNamespaceContext().getNamespaceURI( > nsPrefix); > return (ContactNumbers_type0) > org.opentravel.www.ota._2003._05.ExtensionMapper > .getTypeObject(nsUri, type, reader); > } > > } > > } > > // Note all attributes that were handled. Used to differ > normal > // attributes > // from anyAttributes. > java.util.Vector handledAttributes = new > java.util.Vector(); > > reader.next(); > > java.util.ArrayList list1 = new java.util.ArrayList(); > > while (!reader.isStartElement() && !reader.isEndElement()) > reader.next(); > > if (reader.isStartElement() > && new javax.xml.namespace.QName( > "http://www.opentravel.org/OTA/2003/05", > "ContactNumber").equals(reader.getName())) > { > > // Process the array and step past its final element's > end. > list1 > > .add(org.opentravel.www.ota._2003._05.TelephoneInfoType.Factory > .parse(reader)); > > // loop until we find a start element that is not part > of > // this array > boolean loopDone1 = false; > while (!loopDone1) { > // We should be at the end element, but make sure > while (!reader.isEndElement()) > reader.next(); > // Step out of this element > reader.next(); > // Step to next element event. > while (!reader.isStartElement() > && !reader.isEndElement()) > reader.next(); > >>>>>>>>>> if (reader.isEndElement()) { > // two continuous end elements means we are > exiting > // the xml structure > loopDone1 = true; <<<<<<<<<< > } else { > if (new javax.xml.namespace.QName( > "http://www.opentravel.org/OTA/2003/05 > ", > > "ContactNumber").equals(reader.getName())) { > list1 > > .add(org.opentravel.www.ota._2003._05.TelephoneInfoType.Factory > .parse(reader)); > > } else { > loopDone1 = true; > } > } > } > // call the converter utility to convert and set the > array > > object > > .setContactNumber((org.opentravel.www.ota._2003._05.TelephoneInfoType[]) > org.apache.axis2.databinding.utils.ConverterUtil > .convertToArray( > > org.opentravel.www.ota._2003._05.TelephoneInfoType.class, > list1)); > > } // End of if for expected property start element > > else { > > } > > while (!reader.isStartElement() && !reader.isEndElement()) > reader.next(); > > if (reader.isStartElement()) > // A start element we are not expecting indicates a > trailing > // invalid property > throw new org.apache.axis2.databinding.ADBException( > "Unexpected subelement " + > reader.getLocalName()); > > } catch (javax.xml.stream.XMLStreamException e) { > throw new java.lang.Exception(e); > } > > return object; > } > > -------------------------------------------------------------------------------------------------------------- > > Please advice. > > Many Thanks, > Nateshan > > > On Tue, Dec 30, 2008 at 11:20 PM, Amila Suriarachchi < > amilasuriarach...@gmail.com> wrote: > >> >> >> On Tue, Dec 30, 2008 at 11:46 PM, Nateshan Soundarapandian < >> nates...@gmail.com> wrote: >> >>> Dear Deepal, >>> >>> Thanks for the response. NO, The server side code is not Axis2. However >>> the server side code returns the soap envelope that conforms to the Schema >>> defined in the wsdl. >>> >>> This problem is related to sequences defined in the xsd. >>> >>> >>> Here is what I defined in the Response schema: >>> <xs:element name="ContactNumbers" minOccurs="0"> >>> <xs:complexType> >>> <xs:sequence> >>> <xs:element name="ContactNumber" >>> type="TelephoneInfoType" minOccurs="0" maxOccurs="unbounded"> >>> <xs:annotation> >>> <xs:documentation xml:lang="en">Contact >>> numbers of the hotel property. Examples are telephone and fax >>> numbers.</xs:documentation> >>> </xs:annotation> >>> </xs:element> >>> </xs:sequence> >>> </xs:complexType> >>> >>> Here is the Response: >>> <ContactNumbers> >>> <ContactNumber PhoneNumber="1-305-4469000" PhoneTechType="1" >>> PhoneUseType="5"/> >>> <ContactNumber PhoneNumber="1-305-4471189" PhoneTechType="3" >>> PhoneUseType="5"/> >>> </ContactNumbers> >> >> >> try with this code >> >> String newString = "<ContactNumbers xmlns=\" >> http://www.opentravel.org/OTA/2003/05\<http://www.opentravel.org/OTA/2003/05%5C>">\n" >> + >> "<ContactNumber PhoneNumber=\"1-305-4469000\" >> PhoneTechType=\"1\" PhoneUseType=\"5\"/>\n" + >> "<ContactNumber PhoneNumber=\"1-305-4471189\" >> PhoneTechType=\"3\" PhoneUseType=\"5\"/>\n" + >> "</ContactNumbers>"; >> XMLStreamReader xmlReader = >> StAXUtils.createXMLStreamReader(new >> ByteArrayInputStream(newString.getBytes())); >> ContactNumbers_type0 result = >> ContactNumbers_type0.Factory.parse(xmlReader); >> >> what is the Axis2 version you use? >> thanks, >> Amila. >> >>> >>> >>> Exception: >>> org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: >>> Unexpected subelement ContactNumber >>> at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430) >>> at org.opentravel. >>> www.ota._2003._05.HotelAvailabilityStub.fromOM(HotelAvailabilityStub.java:363)<http://www.ota._2003._05.hotelavailabilitystub.fromom%28hotelavailabilitystub.java:363/> >>> at org.opentravel. >>> www.ota._2003._05.HotelAvailabilityStub.HotelAvailabilityOperation(HotelAvailabilityStub.java:191)<http://www.ota._2003._05.hotelavailabilitystub.hotelavailabilityoperation%28hotelavailabilitystub.java:191/> >>> at >>> com.ihg.ws.cxf.servlets.HotelAvailability.doGet(HotelAvailability.java:211) >>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:114) >>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:91) >>> at >>> com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103) >>> >>> at >>> com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:187) >>> >>> at >>> com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266) >>> >>> at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:270) >>> >>> at com.caucho.server.port.TcpConnection.run(TcpConnection.java:678) >>> at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:721) >>> at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:643) >>> at java.lang.Thread.run(Thread.java:595) >>> >>> Please note: Iam not posting all the schema information here as they are >>> huge. >>> >>> >>> Many Thanks, >>> nateshan >>> >>> >>> >>> On Tue, Dec 30, 2008 at 1:08 PM, Deepal Jayasinghe <dee...@opensource.lk >>> > wrote: >>> >>>> How about the server side code? is it also Axis2? >>>> >>>> You get this error when you receive a message which is not correct >>>> according to its WSDL. >>>> >>>> Deepal >>>> > Hi, >>>> > >>>> > I am new to Axis2. I am having some trouble with the Axis Client code >>>> > that was generated using Axis2 Release 1.4.1. However I wanted to try >>>> > with the nightly builds to see if the problem has been fixed as I see >>>> > so many bug reports on Axis2/ADB UnExpected Sublement errors. >>>> > >>>> > Please advice on where I can download Axis2/Java nightly builds, The >>>> > Axis2 Website only points to a directory where only Axis2/C Nightly >>>> > downloads are available. >>>> > >>>> > Many Thanks, >>>> > Nateshan Soundarapandian >>>> > Amutech Business Solutions Inc >>>> > Mobile:(813) 579-0326 >>>> > Fax: (919) 882-1737 >>>> >>>> -- >>>> Thank you! >>>> >>>> >>>> http://blogs.deepal.org >>>> http://deepal.org >>>> >>>> >>> >> >> >> -- >> Amila Suriarachchi >> WSO2 Inc. >> blog: http://amilachinthaka.blogspot.com/ >> > >