+ Start a Discussion
Micky MMicky M 

Another web service

Hi all, i have this code written in java, ive used java -classpath wsc-23.jar com.sforce.ws.tools.wsdlc MyTestWebMethod.wsdl MyTestWebMethod.jar to create my enterprise and apex class jar and added those to the project. I run this ..

public class QuckSoapTest
{
EnterpriseConnection connection;
ConnectorConfig config = new ConnectorConfig();
String UserName = "soapuser@proact.co.uk.developer";
String Password = "Password12345";

public static void main(String[] args)
{
  new QuckSoapTest().go();
}

public void go()
{
  try
  {
   config.setUsername(UserName);
   config.setPassword(Password);
   connection = Connector.newConnection(config);
  
   System.out.println("Auth Endpoint " + config.getAuthEndpoint());
   System.out.println("Service Endpoint " + config.getServiceEndpoint());
  
   com.sforce.soap.MyTestWebMethod.SoapConnection soap = new com.sforce.soap.MyTestWebMethod.SoapConnection(config);
   soap.setSessionHeader(config.getSessionId());
  
   System.out.println(soap.MyTestWebMethod());
  }
  catch (ConnectionException e)
  {
   e.printStackTrace();
  }
}
}

and i get this error :

Auth Endpoint https://test.salesforce.com/services/Soap/c/31.0/0DFM00000004D7r
Service Endpoint https://cs7.salesforce.com/services/Soap/c/31.0/00DM00000009BGt/0DFM00000004D7r
com.sforce.ws.SoapFaultException: No operation available for request {http://soap.sforce.com/schemas/class/MyTestWebMethod}MyTestWebMethod
at com.sforce.ws.transport.SoapConnection.createException(SoapConnection.java:204)
at com.sforce.ws.transport.SoapConnection.receive(SoapConnection.java:148)
at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:110)
at com.sforce.soap.MyTestWebMethod.SoapConnection.MyTestWebMethod(SoapConnection.java:177)
at quickSoapTest.QuckSoapTest.go(QuckSoapTest.java:34)
at quickSoapTest.QuckSoapTest.main(QuckSoapTest.java:17)

Does anyone have any idea what im doing wrong as im slowly going insane!!! thanks all.
AshwaniAshwani
As I can see here The SOAP endpoint is incorrect.

Service Endpoint should be: https://cs7.salesforce.com/services/Soap/s/31.0/00DM00000009BGt/0DFM00000004D7r

You can use following code to replace:

String serviceUrl = config.getServiceEndpoint().replace("/Soap/c/", "/Soap/s/");



Micky MMicky M
Hi thanks for you help, ok now ive got this

config.setUsername(UserName);
   config.setPassword(Password);
   connection = Connector.newConnection(config);
  
   System.out.println("Auth Endpoint " + config.getAuthEndpoint());
   System.out.println("Service Endpoint " + config.getServiceEndpoint());
  
   String serviceUrl =config.getServiceEndpoint().replace("/Soap/c/", "/Soap/s/");
   config.setServiceEndpoint(serviceUrl);
   System.out.println("Service Endpoint After Change" + config.getServiceEndpoint());
   com.sforce.soap.MyTestWebMethod.SoapConnection soap = new com.sforce.soap.MyTestWebMethod.SoapConnection(config);
   soap.setSessionHeader(config.getSessionId());
  
   System.out.println(soap.MyTestWebMethod());

and the service endpoint is now : https://cs7.salesforce.com/services/Soap/s/31.0/00DM00000009BGt/0DFM00000004D7r

am i doing this is the right place as im still getting:

com.sforce.ws.SoapFaultException: No operation available for request {http://soap.sforce.com/schemas/class/MyTestWebMethod}MyTestWebMethod
at com.sforce.ws.transport.SoapConnection.createException(SoapConnection.java:204)
at com.sforce.ws.transport.SoapConnection.receive(SoapConnection.java:148)
at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:110)
at com.sforce.soap.MyTestWebMethod.SoapConnection.MyTestWebMethod(SoapConnection.java:177)
at quickSoapTest.QuckSoapTest.go(QuckSoapTest.java:44)
at quickSoapTest.QuckSoapTest.main(QuckSoapTest.java:23)

Thanks

Micky MMicky M
Its ok ive fixed it, i wasnt setting the service url to the actual web methods it was pointing to the enterprise wdsl. once i set the service endpoint to the correct url it works.

Thanks for your help!!