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
Sean Fife 9Sean Fife 9 

Tooling API: No operation available for request...

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.
Best Answer chosen by Sean Fife 9
AndreyzhAndreyzh
Hi,

I don't know if you have solved that already or not, but maybe others have same issue.
I figures that the problem is in this section: 
tooling.Url = lr.serverUrl;
partner.Url = lr.serverUrl;
The problem is that tooling and partner APIs have differrent URLs and you're pointing Tooling API to Partner API endpoint. If you look at WSDLs you can see it: 
Tooling: https://cs18.salesforce.com/services/Soap/T/32.0
Partner: https://cs18.salesforce.com/services/Soap/u/32.0

Thus what you have to do is to get the original URL from your partner login result and change it to point to tooling. Assuming you're using C#, it can be done with the simple regex:
partner.Url = lr.serverUrl;
tooling.Url = RegEx.Replace(partnerUrl, "/u/", "/T/");
At least that's how it worked for me :)
 

All Answers

AndreyzhAndreyzh
Hi,

I don't know if you have solved that already or not, but maybe others have same issue.
I figures that the problem is in this section: 
tooling.Url = lr.serverUrl;
partner.Url = lr.serverUrl;
The problem is that tooling and partner APIs have differrent URLs and you're pointing Tooling API to Partner API endpoint. If you look at WSDLs you can see it: 
Tooling: https://cs18.salesforce.com/services/Soap/T/32.0
Partner: https://cs18.salesforce.com/services/Soap/u/32.0

Thus what you have to do is to get the original URL from your partner login result and change it to point to tooling. Assuming you're using C#, it can be done with the simple regex:
partner.Url = lr.serverUrl;
tooling.Url = RegEx.Replace(partnerUrl, "/u/", "/T/");
At least that's how it worked for me :)
 
This was selected as the best answer
Sean Fife 9Sean Fife 9
Yes I had gotten it working, but that was exactly the problem.  I'll mark your answer as correct.