Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-3321

AXIOM based Web_service, getting an unexpected exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Cannot Reproduce
    • None
    • None
    • om
    • None
    • Win XP SP2, java 1.5.13: AXIOM libs: axiom-api-1.2.5.jar, axiom-dom-1.2.5.jar, axiom-impl-1.2.5.jar

    Description

      I have the following snippet of code and i get a very strange
      Exception(possibly a bug, it doesn't make any other sense).

      sample code:

      public OMElement webServiceMethod1(OMElement payload){
      //parse incoming OMElement-> successfully done..
      //Create the XML Model:
      OMFactory fac = OMAbstractFactory.getOMFactory();
      OMNamespace omNs =fac.createOMNamespace("http://authentication.liferay.services.acer.com","xsd");
      OMElement method = fac.createOMElement("authentication_response", omNs);
      //succeed
      OMElement value1 = fac.createOMElement("succeed", null);
      value1.addChild(fac.createOMText(value1, isSuccessful ));
      //authentication_response<- (succeed)
      method.addChild(value1);

      //CRITICAL PART: i try to print all "<method>"'s data: Trying to System.out the OMElement
      way1:
      String response = result.getFirstElement().getText();
      System.out.println("response= "+response);

      And i get: " Exception in thread "main" org.apache.axiom.om.OMException:
      java.lang.ClassCastException: org.apache.axiom.om.impl.llom.OMElementImpl "
      but it doesn't make sense, cause OMElement is of type: OMElementImpl!

      way2:
      OMFactory fac2 = OMAbstractFactory.getOMFactory();
      StAXOMBuilder builder=new StAXOMBuilder(fac2,method.getXMLStreamReader(),method);
      OMElement documentElement=builder.getDocumentElement();
      try

      { System.out.println("xml= "+documentElement.toStringWithConsume()); }

      catch (XMLStreamException e)

      { e.printStackTrace(); }

      And i get:
      "Exception in thread "main" java.lang.IllegalStateException: attribute count
      accessed in illegal event (7)!
      at
      org.apache.axiom.om.impl.llom.OMStAXWrapper.getAttributeCount(OMStAXWrapper.java:636)
      at
      org.apache.axiom.om.impl.builder.StAXBuilder.processAttributes(StAXBuilder.java:177)
      at
      org.apache.axiom.om.impl.builder.StAXOMBuilder.populateOMElement(StAXOMBuilder.java:254)
      at org.apache.axiom.om.impl.builder.StAXOMBuilder.<init>(StAXOMBuilder.java:90)
      at org.apache.axiom.om.impl.builder.StAXOMBuilder.<init>(StAXOMBuilder.java:101)"

      But it doesn't make sense again!

      Attachments

        Activity

          People

            Unassigned Unassigned
            acer acer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: