using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Services.Protocols;
using SFDC_DATAUPLOAD.Importservice;
using SFDC_DATAUPLOAD.enterprise;

    class Program
        static void Main(string[] args)
            string username = "user@gmail.com";
            string password = "password";
            SforceService sforce = null;
            LoginResult logres = new LoginResult();
            sforce = new SforceService();
            logres = sforce.login(username, password);

            PG_ImportWebServiceService dataup = new PG_ImportWebServiceService();
            dataup.SessionHeaderValue = new SFDC_DATAUPLOAD.Importservice.SessionHeader();
            dataup.SessionHeaderValue.sessionId = logres.sessionId;
            //dataup.Url = logres.serverUrl;

            CustomerHierarchy c = new CustomerHierarchy();
            c.country = "France";
            c.descr = "TestDescription";
            c.key = "1";
            c.status = "CREATE";


In this code , I have used two wsdl one is Enterprise.wsdl and another one is Impoertservice.wsdl. while creating connection with salesforce i am getting ERROR Invalid session Id. If i add that commented line that is service url, i'm getting error No operation available for this request. kindly help me to solve this problem.

  • You definitely need to use the server url returned from the LoginResult in addition to the session id. Is createCustomerHierarchy() defined in the same org that you are getting the session for? – Daniel Ballinger Jan 20 '15 at 7:22
  • Create customerHierarchy is defined in ImportService.wdsl – Prasanth Jan 20 '15 at 7:31
  • I'm getting the session ID from Enterprise.wsdl file and assign it to the Importservice.wsdl – Prasanth Jan 20 '15 at 7:38

The endpoint URL from the login result will be for the Enterprise WSDL. It will be something like:


Note the /c/ that indicates it is for the Enterprise WSDL. You will need to change that part as per the soap:address location defined in ImportService.wdsl.

From one of my Apex classes with web service methods the endpoint URL was:


where XYZ was the namespace and TestClass was the name of the hosting Apex class.

Based on your comment, you will want something like:

dataup.Url = 'https://cs17.salesforce.com/services/Soap/class/ImportService';

You should verify this against the URL that appears at the end of the Importservice.wsdl to check that the class name is correct. For example, do you have a namespace defined that needs to be included in the URL.

Ideally you would take this a step further and use the domain returned by the login result with the constant path for the Apex class. That way it will work if you connect to an org on a different pod, such as a sandbox.

  • yes, service url contains /c/ "cs17.salesforce.com/services/Soap/c/33.0/00Dg00000005zFt/…" and help me to solve this. – Prasanth Jan 20 '15 at 10:33
  • It sounds to me that you might be using session Id obtained from an org and using it in combination with another org's serverurl or vice versa. Is importservice.wsdl a custom web service contract or a Salesforce artifact? – Gnana Jan 20 '15 at 20:25
  • Will not all this URL stuff be handled automatically by a developer library of the corresponding language? – Meglio Aug 15 '15 at 5:10
  • @Meglio I don't see how it could unless it was explicitly coded for the differences between the Enterprise WSDL and an Apex Web Service. Maybe when the apex web service wsdl is imported the endpoint will be correctly set. It would depend on the language and what Salesforce pods are involved. – Daniel Ballinger Aug 15 '15 at 7:27
  • 1
    Apex wsdls are per org, if you're using Apex WSDL generated from org A to call orgB you'll need to do the dance to fix up the destination URL. – superfell Aug 15 '15 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.