function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
maybemedicmaybemedic 

Error: Compile Error: Method does not exist or incorrect signature:

Hello All,
               I am trying to develop a class that would just get an XML string and return all the text contained in it, in apex. I am fairly new to apex. I get the following exception,,

Error: Compile Error: Method does not exist or incorrect signature: parseXmlStream) at line 17 column 33

Attached is the code that I developed,

Code:
global class ProcessXmlStream
{
    webservice static String getXmlStream(String xmlString)
    {
        String returnField = '';
        XmlStreamReader xmlReader = new XmlStreamReader(xmlString);
        try 
        {
         while (xmlReader.hasNext()) 
         {
          if (xmlReader.getEventType()  == XmlTag.START_ELEMENT) 
           {
            if (xmlReader.getLocalName() == 'acccon')
             {
               returnField = parseXmlStream(xmlReader);
             }       
           }   
           xmlReader.next();
         }   
        } // END OF TRY BLOCK
        catch(Exception ex)
        {
            throw ex;
        }
        return returnField ;
    }
    private String parseXmlStream(XmlStreamReader xmlReader) 
    {
     String xmlText = '';
     try 
     {
      while (xmlReader.hasNext()) 
      {
       if (xmlReader.getEventType()  == XmlTag.START_ELEMENT) 
        if (xmlReader.getLocalName() == 'acc')
          xmlText = xmlReader.getText();
        else if (xmlReader.getLocalName() == 'con')
           xmlText = xmlReader.getText();
        else if (xmlReader.getEventType() == XmlTag.END_ELEMENT) 
        {
         if (xmlReader.getLocalName() == 'acccon')
          break;
        }   
           // IF IT HAS REACHED THE END TAG OF AN acccon THEN Return back             
         xmlReader.next();
        }   
      }   
 catch (Exception e) {
            throw new RuntimeException('***Parse Exception: '  + e.getMessage()); 
        }   
        return xmlText;
    }   
    }// End of class

 I was getting the same exception when I was trying to return the entire xml text in a string array. Then I thought of trying to return atleast one text just by returning a string. I am out of conventional logic here , do not understand why I am getting this excpetion when I try to save. Any help in this regard is greatly appreciated.

SuperfellSuperfell
you're trying to call a non-static method from a static method, which won't work because it doesn't have an instance of the object, either create an instance, or make your parseXmlStream method static as well.
maybemedicmaybemedic
Opps My bad have no idea how I missed it. Thanks so much Simon.