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
Saranya MSaranya M 

Web service callout failed: WebService returned a SOAP Fault: No service available for class

How to call a soap webservice

I am trying to consume a Soap webservice.  I have generated a class(partnerSoapSforceCom.Soap)  from Partner WSDL. Also I have generated a class(soapSforceComSchemasClassSaransoaps) from the WSDL created from custom webservice.  The webservice contains a single method named Hello which accepts a string and displays a string.

I'm new to integration. When I execute the below code, I'm getting an error msg 'System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: No service available for class'. Please someone help me to modify it.

WEbservice : 

global class SaranSoapService
{
    webService static String hello(String Name)
    {
        return 'Hi '+Name+' ! :D';
    }
}

This is the code which I executed.

partnerSoapSforceCom.Soap sp = new partnerSoapSforceCom.Soap();
String username = 'My username;
String password = 'My password';
partnerSoapSforceCom.LoginResult loginResult = sp.login(username, password);
system.debug('   loginResult ' + loginResult);
system.debug(loginresult.sessionid);
soapSforceComSchemasClassSaransoaps  ap = new soapSforceComSchemasClassSaransoaps();
soapSforceComSchemasClassSaransoaps.SessionHeader_element sessionHeader = new soapSforceComSchemasClassSaransoaps.SessionHeader_element ();
sessionHeader.sessionId = loginResult.sessionId;
soapSforceComSchemasClassSaransoaps.SaranSoapService callsoap = new  soapSforceComSchemasClassSaransoaps.SaranSoapService();
string retval=callsoap.hello('Saranya');
system.debug(retval);