You need to sign in to do that
Don't have an account?
Sunukrish
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(); |
03 | LoginResult lr = binding.login(username, password); |
04 | binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, lr |
05 | .getServerUrl()); |
06 | SessionHeader sh = new SessionHeader(); |
07 | sh.setSessionId(lr.getSessionId()); |
08 | binding.setHeader(new SforceServiceLocator().getServiceName() |
09 | .getNamespaceURI(), "SessionHeader", sh); |
10 | ApexBindingStub apexBinding = (ApexBindingStub) new ApexServiceLocator() |
11 | .getApex(); |
12 | /* |
13 | Line below was cause of problem, I was setting incorrect url for binding end point. |
14 | */ |
15 | apexBinding._setProperty(ApexBindingStub.ENDPOINT_ADDRESS_PROPERTY, |
16 | lr.getServerUrl()); |
17 |
18 | // Apex Session Header |
19 | com.sforce.soap._2006._08.apex.SessionHeader ash = new com.sforce.soap._2006._08.apex.SessionHeader(); |
20 | ash.setSessionId(lr.getSessionId()); |
21 | apexBinding.setHeader(new ApexServiceLocator().getServiceName() |
22 | .getNamespaceURI(), "SessionHeader", ash); |
23 |
24 | RunTestsRequest runTestsRequest = new RunTestsRequest(false, |
25 | new String[] { "TestFooBar" }, "myns", null); |
26 | RunTestsResult runTests = apexBinding.runTests(runTestsRequest); |
27 | System.out.println("Failures " + runTests.getNumFailures()); |
Metadata WSDL/ENDPOINT URL : https://[api node].salesforce.com/services/Soap/m/18.0/[org-id] |
03 | Partner WSDL/ENDPOINT URL : https://[api node].salesforce.com/services/Soap/u/18.0/[org-id] |
04 |
05 | Both these URLs can be fetched via LoginResult.getServerUrl() and LoginResult.getMetadataServerUrl(). But there is no direct method for Apex WSDL URL. |
06 | Though Apex WSDL/ENDPOINT URL is simply one char change |
07 | https://[api node].salesforce.com/services/Soap/s/18.0/[org-id] |
08 | So here is the trick, and the above code snippet will work fine then. |
09 | */ |
10 | apexBinding._setProperty(ApexBindingStub.ENDPOINT_ADDRESS_PROPERTY, |
11 | lr.getServerUrl().replaceAll("/u/", "/s/")); |
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.