You need to sign in to do that
Don't have an account?

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?
TIA,
All Answers
I imported the new WSDL. It has changed since I added the namespace:
- <definitions targetNamespace=http://soap.sforce.com/schemas/class/NAMESPACE/CLASSNAME xmlns:xsd="http://www.w3.org/2001/XMLSchema" ...
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="https://na4-api.salesforce.com/services/Soap/class/NAMESPACE/CLASSNAME"/>
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=http://soap.sforce.com/schemas/class/NAMESPACE/CLASSNAME)]
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?
TIA,
John
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=http://soap.sforce.com/schemas/class/NAMESPACE/CLASSNAME, ResponseNamespace=http://soap.sforce.com/schemas/class/NAMESPACE/CLASSNAME, 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 Force.com Web Services API (http://www.salesforce.com/us/developer/docs/api/index.htm) 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 Force.com 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.
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()) {
logger.info("Logging into Sandbox");
slocator.setSoapEndpointAddress(Constants.SandboxSoapEndPoint);
}
binding = (SoapBindingStub)slocator.getSoap();
loginResult = binding.login(config.getUserName(), config.getPwd());
binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, loginResult.getServerUrl());
SessionHeader sh = new SessionHeader();
sh.setSessionId(loginResult.getSessionId());
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">
<documentation/>
−
<port binding="tns:MyWebServiceBinding" name="MyWebService">
<soap:address location="https://cs2-api.salesforce.com/services/Soap/class/MyWebService"/>
</port>
</service>