• maybemedic
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 10
    Replies
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.

Hello All,
             I am fairly new to apex development. I have developed an apex class that would accept an xml string, parse it and returns the parsed elements back. Just for testing purposes. I am getting the following exception back,,,

"No operation available for request {http://soap.sforce.com/schemas/class/TerminateAC}processXmlDataStream"

Here I am not trying to hit a secure URL, just using http:// since we are passing the token that we get as a result of the login call(EndpointURL), just to avoid using certificates. I have done this earlier and it works. I am just wondering that if my client is not able to find the service at

https://cs2-api.salesforce.com/services/Soap/class/TerminateAC

The simple code I developed is,

Code:
global class TerminateAC
{
webservice static String[] processXmlDataStream(String data )
{
XmlStreamReader xmlReader = new XmlStreamReader(data);
String[] gotAC = new String[0];
String xmlText = '';
//String[] result = new String[0];
try
{
while (xmlReader.hasNext())
{
if (xmlReader.getEventType() == XmlTag.START_ELEMENT && xmlReader.getLocalName() == 'AC')
{
//xmlReader.next();
if(xmlReader.getEventType() == XmlTag.START_ELEMENT && xmlReader.getLocalName() == 'A')
{
xmlText = xmlReader.getText();
gotAC.add(xmlText);
System.debug('Got data ---> ' + xmlText);

}
if(xmlReader.getEventType() == XmlTag.START_ELEMENT && xmlReader.getLocalName() == 'C')
{
xmlText = xmlReader.getText();
gotAC.add(xmlText);
System.debug('Got data ---> ' + xmlText);
}
}
else if (xmlReader.getEventType() == XmlTag.END_ELEMENT && xmlReader.getLocalName() == 'AC')
break;
xmlReader.next();
}
}
catch(XmlException ex)
{
ex.getMessage();
}
catch(Exception ex)
{
ex.getMessage();
}
return gotAC;
}//End ProcessXmlStreamData

static testMethod void testProcessXmlDataStream() {
String sText = '';

String xmlData = '<—xml version="1.0" encoding="UTF-8"–>';
xmlData += '<AC xsi:noNamespaceSchemaLocation="AC.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
xmlData += '<A>a0770000002IHMz</A>';
xmlData += '<A>a0770000002yHvz</A>';
xmlData += '<A>a0770000002IoMz</A>';
xmlData += '<C>a077000000iIpMz</C>';
xmlData += '<C>a077000j002IlMz</C>';
xmlData += '</AC>';

TerminateAC.processXmlDataStream(xmlData);
}

}

 I am not able to get where I am going wrong. I'd like to know if there is a way to get stack trace when we run a code in force.com platform??

I verified an earlier WSDL from an apex class with the one I generated, I dont see a problem with mine, only that in the earlier working version(different interface), the return type is a user define class and to keep things simple I've used a String[ ]. I believe SOAP supports it.The data I am sending is

<?xml version="1.0" encoding="UTF-8"?> <AC xmlns="http://www.xyz.com/schemas/CopyFiles/Schema.xsd">     <A>123456</A>     <C>2345</C> </AC>


I'd appreciate any help in this regard. Thanks all.
Hello All,
              I am fairly new to apex development. I created a class in our orgs sandbox and I tried the option of refreshing from server in the force.com IDE. The most recent class that I put in SF is not being refreshed onto eclipse. But if I create a class in eclipse and try saving it onto the server, thats working. But the other way is not. I am using IDE 14.01 and API Ver 14. Also, I tried executing the apex code in the "System Log", I get an exception

 "ERROR - Compile error: Global type must be contained inside of a global class ",

but I am able to save the code in apex editor so I believe that means it compiled successfully. I am just wondering if the exception could have been the problem. I tried searching the board for any clarification on this problem but couldn't find one that answers me. I'd appreciate any help in this regard. Thanks all.



Message Edited by maybemedic on 12-30-2008 11:36 AM
Hello All,
               I am trying to expose an Apex class as a web service. Earlier I have built a client from outside SF to invoke services from SF. The apex developer then said that there is no way he could send faults from SF. So I had to parse the response at the client for some code like "FAIL"/"SUCCESS". Now I am involved in some apex development and I'd like to know if there is any way force.com platform WSDL generator would include fault shcema in the WSDL it generates for an apex class.I'd appreciate any help in this regards. Thanks all.
Hello All,
              I am new to Apex development and I am going through the Apex reference document. I am trying to save a sample code in the doc, but it keeps giving me the Exception "Constructor Not defined". I am using the web interface on my DEV edition. It happens in Eclipse too. I'd appreciate if I get some help in this regard. Thanks.
Code:
public class XmlStreamReader
{
    // Create a class Book for processing
    public class Book 
    {
        String name;
        String author;
    }
    Book[] parseBooks(XmlStreamReader reader) 
    {
        Book[] books = new Book[0];
        while(reader.hasNext()) 
        {
            // Start at the beginning of the book and make sure that it is a book
            if (reader.getEventType() == XmlTag.START_ELEMENT)
            {
                if (reader.getLocalName()=='Book') 
                {
                    // Pass the book to the parseBook method (below)
                    Book book = parseBook(reader);
                    books.add(book);
                }
            }
            reader.next();
        }
    return books;
    }

// Parse through the XML, deterimine the auther and the characters
Book parseBook(XmlStreamReader reader) 
{
    Book book = new Book();
    book.author = reader.getAttributeValue('', 'author');
    while(reader.hasNext()) 
    {
        if (reader.getEventType() == XmlTag.END_ELEMENT) 
        {
            break;
        } 
        else if (reader.getEventType() == XmlTag.CHARACTERS) 
        {
            book.name = reader.getText();
        }
    reader.next();
    }
return book;
}

// Test that the XML string contains specific values
static testMethod void testBookParser() 
{
    XmlStreamReader demo = new XmlStreamReader();
    String str = '<books><book author="Manoj">Foo bar</book>' +
    '<book author="Mysti">Baz</book></books>';
    XmlStreamReader reader = new XmlStreamReader(str);
    Book[] books = demo.parseBooks(reader);
    System.debug(books.size());
    for (Book book : books) 
    {
        System.debug(book);
    }
}
}

 

Hello All,
               I am very new to Salesforce.com platform. We have a package in our sandbox(We have unlimited edition) created by someone earlier. My questions are

1. If I need to add some custom objects to the same app. The team that developed earlier does not want us to touch anything in their sandbox. Since we have an unlimited edition, I believe we can create another sandbox of our own. If so how to we go about doing this, since Setup --> Data Management does not show a link to "Sandbox". Is this something that our organizations admin should be doing?

2. Ramifying from my earlier question, in case I need to develop a custom object is it best to do it in our own sandbox or should I be installing the package developed already to my "Developer Edition"?

3. If I need to install the package to the "Developer Edition" could someone please elaborate on how to go about doing this since the AppExchange documentation is not clear on this?
I already have a link to the package to the earlier app from their sandbox, my question is how to use this link.

Any help in this regard is greatly appreciated. Thanks all.
Hello All,
               I am very new to Salesforce.com. I started following the Apex getting started book. I tried creating a custom object from Eclipse 3.3.2. I get the following exception, "Unknown exception Unable to create custom object 'Objectname__c'" and the following exception code 1167122361-115. Has anyone faced this issue?. In one of the posting I read that we should be using Eclipse 3.2.2. I would like to know if this is the issue before actually spending time on installing an earlier version of Eclipse. Any help is greatly appreciated. Thanks all.

Hello All,
              I am very new to Salesforce just a couple of days old. I am not even a Salesforce resource, but given the responsibility of making some changes to an existing object. We have an object with several fields. The requirement is that if a particular picklist value say, ABC_c is selected then three text fields need to be validated accordingly, i.e if ABC_c picklist is selected, then the user that enters values in these three text fields should enter atleast 10 chars long string, if not an error should be thrown to the user. I can see that we could create dependency between picklists, but this case of a picklist and text field, I am unaware of it. Any help is greatly appreciated. Also, it would be great if someone could point me to a tutorial where I can learn to write these validation rules. Thanks a zillion.

hi all,

I am new to force.com platform.

can any one of plz tel me how to generate java source by using wsdl file.

Here i am little confused too:(

 

there are options are there to use an enterprise wsdl and partner wsdl.

along with them we have a seperate generate wsdl for each apex class.which one to use to generate the java code.

and if possible plz send me some code snippets.

 

thanks a lot..

chandra.

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.

Hello All,
             I am fairly new to apex development. I have developed an apex class that would accept an xml string, parse it and returns the parsed elements back. Just for testing purposes. I am getting the following exception back,,,

"No operation available for request {http://soap.sforce.com/schemas/class/TerminateAC}processXmlDataStream"

Here I am not trying to hit a secure URL, just using http:// since we are passing the token that we get as a result of the login call(EndpointURL), just to avoid using certificates. I have done this earlier and it works. I am just wondering that if my client is not able to find the service at

https://cs2-api.salesforce.com/services/Soap/class/TerminateAC

The simple code I developed is,

Code:
global class TerminateAC
{
webservice static String[] processXmlDataStream(String data )
{
XmlStreamReader xmlReader = new XmlStreamReader(data);
String[] gotAC = new String[0];
String xmlText = '';
//String[] result = new String[0];
try
{
while (xmlReader.hasNext())
{
if (xmlReader.getEventType() == XmlTag.START_ELEMENT && xmlReader.getLocalName() == 'AC')
{
//xmlReader.next();
if(xmlReader.getEventType() == XmlTag.START_ELEMENT && xmlReader.getLocalName() == 'A')
{
xmlText = xmlReader.getText();
gotAC.add(xmlText);
System.debug('Got data ---> ' + xmlText);

}
if(xmlReader.getEventType() == XmlTag.START_ELEMENT && xmlReader.getLocalName() == 'C')
{
xmlText = xmlReader.getText();
gotAC.add(xmlText);
System.debug('Got data ---> ' + xmlText);
}
}
else if (xmlReader.getEventType() == XmlTag.END_ELEMENT && xmlReader.getLocalName() == 'AC')
break;
xmlReader.next();
}
}
catch(XmlException ex)
{
ex.getMessage();
}
catch(Exception ex)
{
ex.getMessage();
}
return gotAC;
}//End ProcessXmlStreamData

static testMethod void testProcessXmlDataStream() {
String sText = '';

String xmlData = '<—xml version="1.0" encoding="UTF-8"–>';
xmlData += '<AC xsi:noNamespaceSchemaLocation="AC.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
xmlData += '<A>a0770000002IHMz</A>';
xmlData += '<A>a0770000002yHvz</A>';
xmlData += '<A>a0770000002IoMz</A>';
xmlData += '<C>a077000000iIpMz</C>';
xmlData += '<C>a077000j002IlMz</C>';
xmlData += '</AC>';

TerminateAC.processXmlDataStream(xmlData);
}

}

 I am not able to get where I am going wrong. I'd like to know if there is a way to get stack trace when we run a code in force.com platform??

I verified an earlier WSDL from an apex class with the one I generated, I dont see a problem with mine, only that in the earlier working version(different interface), the return type is a user define class and to keep things simple I've used a String[ ]. I believe SOAP supports it.The data I am sending is

<?xml version="1.0" encoding="UTF-8"?> <AC xmlns="http://www.xyz.com/schemas/CopyFiles/Schema.xsd">     <A>123456</A>     <C>2345</C> </AC>


I'd appreciate any help in this regard. Thanks all.
Hello All,
              I am fairly new to apex development. I created a class in our orgs sandbox and I tried the option of refreshing from server in the force.com IDE. The most recent class that I put in SF is not being refreshed onto eclipse. But if I create a class in eclipse and try saving it onto the server, thats working. But the other way is not. I am using IDE 14.01 and API Ver 14. Also, I tried executing the apex code in the "System Log", I get an exception

 "ERROR - Compile error: Global type must be contained inside of a global class ",

but I am able to save the code in apex editor so I believe that means it compiled successfully. I am just wondering if the exception could have been the problem. I tried searching the board for any clarification on this problem but couldn't find one that answers me. I'd appreciate any help in this regard. Thanks all.



Message Edited by maybemedic on 12-30-2008 11:36 AM
Hello All,
              I am new to Apex development and I am going through the Apex reference document. I am trying to save a sample code in the doc, but it keeps giving me the Exception "Constructor Not defined". I am using the web interface on my DEV edition. It happens in Eclipse too. I'd appreciate if I get some help in this regard. Thanks.
Code:
public class XmlStreamReader
{
    // Create a class Book for processing
    public class Book 
    {
        String name;
        String author;
    }
    Book[] parseBooks(XmlStreamReader reader) 
    {
        Book[] books = new Book[0];
        while(reader.hasNext()) 
        {
            // Start at the beginning of the book and make sure that it is a book
            if (reader.getEventType() == XmlTag.START_ELEMENT)
            {
                if (reader.getLocalName()=='Book') 
                {
                    // Pass the book to the parseBook method (below)
                    Book book = parseBook(reader);
                    books.add(book);
                }
            }
            reader.next();
        }
    return books;
    }

// Parse through the XML, deterimine the auther and the characters
Book parseBook(XmlStreamReader reader) 
{
    Book book = new Book();
    book.author = reader.getAttributeValue('', 'author');
    while(reader.hasNext()) 
    {
        if (reader.getEventType() == XmlTag.END_ELEMENT) 
        {
            break;
        } 
        else if (reader.getEventType() == XmlTag.CHARACTERS) 
        {
            book.name = reader.getText();
        }
    reader.next();
    }
return book;
}

// Test that the XML string contains specific values
static testMethod void testBookParser() 
{
    XmlStreamReader demo = new XmlStreamReader();
    String str = '<books><book author="Manoj">Foo bar</book>' +
    '<book author="Mysti">Baz</book></books>';
    XmlStreamReader reader = new XmlStreamReader(str);
    Book[] books = demo.parseBooks(reader);
    System.debug(books.size());
    for (Book book : books) 
    {
        System.debug(book);
    }
}
}

 

Hello All,
               I am very new to Salesforce.com platform. We have a package in our sandbox(We have unlimited edition) created by someone earlier. My questions are

1. If I need to add some custom objects to the same app. The team that developed earlier does not want us to touch anything in their sandbox. Since we have an unlimited edition, I believe we can create another sandbox of our own. If so how to we go about doing this, since Setup --> Data Management does not show a link to "Sandbox". Is this something that our organizations admin should be doing?

2. Ramifying from my earlier question, in case I need to develop a custom object is it best to do it in our own sandbox or should I be installing the package developed already to my "Developer Edition"?

3. If I need to install the package to the "Developer Edition" could someone please elaborate on how to go about doing this since the AppExchange documentation is not clear on this?
I already have a link to the package to the earlier app from their sandbox, my question is how to use this link.

Any help in this regard is greatly appreciated. Thanks all.
Hello All,
              I am very new to Salesforce just a couple of days old. I am not even a Salesforce resource, but given the responsibility of making some changes to an existing object. We have an object with several fields. The requirement is that if a particular picklist value say, ABC_c is selected then three text fields need to be validated accordingly, i.e if ABC_c picklist is selected, then the user that enters values in these three text fields should enter atleast 10 chars long string, if not an error should be thrown to the user. I can see that we could create dependency between picklists, but this case of a picklist and text field, I am unaware of it. Any help is greatly appreciated. Also, it would be great if someone could point me to a tutorial where I can learn to write these validation rules. Thanks a zillion.