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

Adding Namespace to Webservice Class Name

I have almost gotten my webservice working, first in dev, then in prod, due to the help I've been getting on here. Thanks, Simon!


Last question, I hope: I added a namespace to my webservice so that the package could be managed and now it fails with the error message "No service available for class [CLASSNAME]". I found some posts on here that said to resolve this, I need to add the namespace to my classname.


How? I tried changing the classname in the service, but the package is now managed and therefore won't let me.


I am calling the webservice from C#. I regenerated the WSDL after adding the namespace, and my interface code is generated from the WSDL. I'm not sure where I could add the namespace in this.


Or is there something else going on?



Best Answer chosen by Admin (Salesforce Developers) 
There was an orphaned reference to the OLD webservice in the app.config file in one of the projects. When I removed that, everything started working. Thanks Simon!

All Answers

Make sure you've imported the new WSDL, and are using the new service URL from that WSDL.

I imported the new WSDL. It has changed since I added the namespace:


- <definitions targetNamespace= xmlns:xsd="" ...


By this I mean that the NAMESPACE element was not there before. I think this is what you mean by the new service URL:


<soap:address location=""/>


Again, the NAMESPACE element was not there before. The autogenerated reference.cs code file also refers to the new namespace, I think:


[System.Web.Services.WebServiceBindingAttribute(Name="CLASSNAMEBinding", Namespace=]


So I'm pretty sure that I have imported the correct WSDL.


I have also verified that the webservice class has permissions for the API user making the call.


But I keep getting the same "No service available for class CLASSNAME" error message.


It does occur to me that I don't really know what you mean by "[you] are using the new service URL from that WSDL". If I import the WSDL, that's all I have to do, right?





Just to be sure, I tested the webservice using a different user with full system administrator credentials and got the same error.

This is the actual call that is failing (from reference.cs):


[System.Web.Services.Protocols.SoapHeaderAttribute("DebuggingHeaderValue")] [System.Web.Services.Protocols.SoapHeaderAttribute("AllowFieldTruncationHeaderValue")] [System.Web.Services.Protocols.SoapHeaderAttribute("SessionHeaderValue")] [System.Web.Services.Protocols.SoapHeaderAttribute("DebuggingInfoValue", Direction=System.Web.Services.Protocols.SoapHeaderDirection.Out)] [System.Web.Services.Protocols.SoapHeaderAttribute("CallOptionsValue")] [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace=, ResponseNamespace=, Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] [return: System.Xml.Serialization.XmlElementAttribute("result", IsNullable=true)] public validationResult validate([System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] validationRequest request) { object[] results = this.Invoke("validate", new object[] { request}); return ((validationResult)(results[0])); }





I found some instructions in the Web Services API ( that said:


To access an XML Web service from managed code: Add a Web reference to your project for the XML Web service that you want to access. The Web reference creates a proxy class with methods that serve as proxies for each exposed method of the XML Web service. Add the namespace for the Web reference. Create an instance of the proxy class and then access the methods of that class as you would the methods of any other class. To add a Web reference: On the Project menu, choose Add Web Reference. In the URL box of the Add Web Reference dialog box, type the URL to obtain the service description of the XML Web service you want to access, such as: file:///c:\WSDLFiles\enterprise.wsdl Click Go to retrieve information about the XML Web service. In the Web reference name box, rename the Web reference to sforce, which is the namespace you will use for this Web reference. Click Add Reference to add a Web reference for the target XML Web service. For more information, see the topic “Adding and Removing Web References” in the Visual Studio documentation. Visual Studio retrieves the service description and generates a proxy class to interface between your application and the XML Web service.



Obviously this is intended for but I assume it applies to any web service, so I changed my web reference name to be the same as my namespace.


Same error.

well, there are configs and programatic ways to change the Url property on the stub, so just importing the new WSDL may not be enough to pick up the new URL, depending on how your application is built. check the .url property on your stub just before making the call that's failing.
There was an orphaned reference to the OLD webservice in the app.config file in one of the projects. When I removed that, everything started working. Thanks Simon!
This was selected as the best answer

I am getting a similar issue when I point my Java code to a different Sandbox instance (cs3 instead of cs2). I have a webservice generated for an Apex Class. 


I am already repointing to the server URL that I get.



  SforceServiceLocator slocator = new SforceServiceLocator();

if (config.isSandbox()) {"Logging into Sandbox");
binding = (SoapBindingStub)slocator.getSoap();
loginResult = binding.login(config.getUserName(), config.getPwd());
binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, loginResult.getServerUrl());
SessionHeader sh = new SessionHeader();
binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(), "SessionHeader", sh);


Seems like the issue is probably something to do with the  SOAP Address in the WSDL.




<service name="MyWebService">

<port binding="tns:MyWebServiceBinding" name="MyWebService">
<soap:address location=""/>






Message Edited by GoForceGo on 03-31-2009 11:23 AM