• Andreyzh
  • NEWBIE
  • 25 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
I've been trying to use the tooling api with no luck.  After I found this post (https://success.salesforce.com/issues_view?id=a1p30000000T2GcAAK ) I tried the work around, but it's not working for me.  I get "No operation available for request {urn:tooling.soap.sforce.com}create" on the code below.  Anyone know whta's wrong?

I'm using VS2013 Pro with C#.

here's my code:
sfdc.tooling.SforceServiceService tooling;
        sfdc.partner.SforceService partner;
        private void Form1_Load(object sender, EventArgs e)
        {
            if (Login())
            {
                string classBody = "public class Messages {\n"
                      + "public string SayHello() {\n"
                      + " return 'Hello';\n" + "}\n"
                      + "}";

                // create a new ApexClass object and set the body 
                sfdc.tooling.ApexClass apexClass = new sfdc.tooling.ApexClass();
                apexClass.Body = classBody;
                sfdc.tooling.ApexClass[] classes = new sfdc.tooling.ApexClass[]{ apexClass };

                // call create() to add the class
                sfdc.tooling.SaveResult[] saveResults = tooling.create(classes);//error here
                for (int i = 0; i < saveResults.Length; i++)
                {
                    if (saveResults[i].success)
                    {
                        Console.WriteLine("Successfully created Class: " +
                         saveResults[i].id);
                    }
                    else
                    {
                        Console.WriteLine("Error: could not create Class ");
                        Console.WriteLine("   The error reported was: " +
                        saveResults[i].errors[0].message + "\n");
                    }
                }

                tooling.logout();
            }
        }

        private bool Login()
        {
            bool success = false;
            try
            {
                tooling = new sfdc.tooling.SforceServiceService();
                partner = new sfdc.partner.SforceService();

                sfdc.partner.LoginResult lr;

                lr = partner.login(username, password + secretkey);
                success = true;

                string authEndPoint = tooling.Url;
                tooling.Url = lr.serverUrl;
                partner.Url = lr.serverUrl;

                tooling.SessionHeaderValue = new sfdc.tooling.SessionHeader();
                tooling.SessionHeaderValue.sessionId = lr.sessionId;
            }
            catch( SoapException e)
            {
                MessageBox.Show("Login failed: " + e.Message);
                //success = false;
            }

            return success;
        }

Thanks in advance.
I've been trying to use the tooling api with no luck.  After I found this post (https://success.salesforce.com/issues_view?id=a1p30000000T2GcAAK ) I tried the work around, but it's not working for me.  I get "No operation available for request {urn:tooling.soap.sforce.com}create" on the code below.  Anyone know whta's wrong?

I'm using VS2013 Pro with C#.

here's my code:
sfdc.tooling.SforceServiceService tooling;
        sfdc.partner.SforceService partner;
        private void Form1_Load(object sender, EventArgs e)
        {
            if (Login())
            {
                string classBody = "public class Messages {\n"
                      + "public string SayHello() {\n"
                      + " return 'Hello';\n" + "}\n"
                      + "}";

                // create a new ApexClass object and set the body 
                sfdc.tooling.ApexClass apexClass = new sfdc.tooling.ApexClass();
                apexClass.Body = classBody;
                sfdc.tooling.ApexClass[] classes = new sfdc.tooling.ApexClass[]{ apexClass };

                // call create() to add the class
                sfdc.tooling.SaveResult[] saveResults = tooling.create(classes);//error here
                for (int i = 0; i < saveResults.Length; i++)
                {
                    if (saveResults[i].success)
                    {
                        Console.WriteLine("Successfully created Class: " +
                         saveResults[i].id);
                    }
                    else
                    {
                        Console.WriteLine("Error: could not create Class ");
                        Console.WriteLine("   The error reported was: " +
                        saveResults[i].errors[0].message + "\n");
                    }
                }

                tooling.logout();
            }
        }

        private bool Login()
        {
            bool success = false;
            try
            {
                tooling = new sfdc.tooling.SforceServiceService();
                partner = new sfdc.partner.SforceService();

                sfdc.partner.LoginResult lr;

                lr = partner.login(username, password + secretkey);
                success = true;

                string authEndPoint = tooling.Url;
                tooling.Url = lr.serverUrl;
                partner.Url = lr.serverUrl;

                tooling.SessionHeaderValue = new sfdc.tooling.SessionHeader();
                tooling.SessionHeaderValue.sessionId = lr.sessionId;
            }
            catch( SoapException e)
            {
                MessageBox.Show("Login failed: " + e.Message);
                //success = false;
            }

            return success;
        }

Thanks in advance.

Can anyone provide me the sample code to set username and password for a Apex code callout. I see most of the people set certification. But i am looking for some sample code where in we can set user name and password to the webservice client call.

 

In my case i am trying to consume a SAP Wervice from Apex code generated by WSDL.

  • August 19, 2011
  • Like
  • 0