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
SunukrishSunukrish 

No operation available for the request... while using apex wsdl in java code

Hi,

 

We get an error stating "no operation available for the request..." when we are trying to bind the apexwsdl to create trigger programmatically.This issue is due to endpoint url not been set properly.Please find the sample which helped us in resolving the issue,posted by Abhinav gupta on a blog.

 

SoapBindingStub binding = (SoapBindingStub) new SforceServiceLocator()
02        .getSoap();
03LoginResult lr = binding.login(username, password);
04binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, lr
05        .getServerUrl());
06SessionHeader sh = new SessionHeader();
07sh.setSessionId(lr.getSessionId());
08binding.setHeader(new SforceServiceLocator().getServiceName()
09        .getNamespaceURI(), "SessionHeader", sh);
10ApexBindingStub apexBinding = (ApexBindingStub) new ApexServiceLocator()
11        .getApex();
12/*
13Line below was cause of problem, I was setting incorrect url for binding end point.
14*/
15apexBinding._setProperty(ApexBindingStub.ENDPOINT_ADDRESS_PROPERTY,
16        lr.getServerUrl());
17  
18// Apex Session Header
19com.sforce.soap._2006._08.apex.SessionHeader ash = new com.sforce.soap._2006._08.apex.SessionHeader();
20ash.setSessionId(lr.getSessionId());
21apexBinding.setHeader(new ApexServiceLocator().getServiceName()
22        .getNamespaceURI(), "SessionHeader", ash);
23  
24RunTestsRequest runTestsRequest = new RunTestsRequest(false,
25        new String[] { "TestFooBar" }, "myns", null);
26RunTestsResult runTests = apexBinding.runTests(runTestsRequest);
27System.out.println("Failures " + runTests.getNumFailures());

 

Metadata WSDL/ENDPOINT URL : https://[api node].salesforce.com/services/Soap/m/18.0/[org-id]
03Partner WSDL/ENDPOINT URL : https://[api node].salesforce.com/services/Soap/u/18.0/[org-id]
04  
05Both these URLs can be fetched via LoginResult.getServerUrl() and LoginResult.getMetadataServerUrl(). But there is no direct method  for Apex WSDL URL. 
06Though Apex WSDL/ENDPOINT URL is simply one char change
07https://[api node].salesforce.com/services/Soap/s/18.0/[org-id]
08So here is the trick, and the above code snippet will work fine then.
09*/
10apexBinding._setProperty(ApexBindingStub.ENDPOINT_ADDRESS_PROPERTY,
11    lr.getServerUrl().replaceAll("/u/", "/s/"));
zhang gjzhang gj
Hi Sunukrish 
I import the salesforce API generation jar into Eclipse, but ApexServiceLocator.java class/ApexBindingStub.java class  etc., still can't find it, can you help me? Thank you very much.
User-added image