You need to sign in to do that
Don't have an account?
Helen He 7
How to get the list of current Apex Web Services
Hello,
New to Salesforce, and am learning Apex web services.
Assume there is no source-driven development in our team, and developers write their own web services through console, how can I get the whole list of existing Apex web services, any utilities or I have to open each Apex class to figure out?
Thanks.
New to Salesforce, and am learning Apex web services.
Assume there is no source-driven development in our team, and developers write their own web services through console, how can I get the whole list of existing Apex web services, any utilities or I have to open each Apex class to figure out?
Thanks.
The code above is "minimalist" (+ zero installation) and not "handy" when you cannot get the result easily from the log with a lot of web services.
I know other techniques but they are even more technical and I am rarely a success witth them.
You have opened end points but that is not sufficient to get all the web service names.
The most appreciated solution would be a simple appexchange free application ( https://appexchange.salesforce.com/ (https://appexchange.salesforce.com/) )
It is easy to add a small form with a caller button and to get the result on screen in a basic textarea field ( + copy/paste) with the code above.
All Answers
If you use SOAP, your Apex web services use WebServiceCallout and its method invoke.
There is also the simplest Rest call for the web services.
SOAP : invoke(stub, request, response, infoArray)) )
Invokes an external SOAP web service operation based on an Apex class that is auto-generated from a WSDL.
infoArray: Type: String[]
An array of strings that contains information about the callout—web service endpoint, SOAP action, request, and response. The order of the elements in the array matters.
Element at index 0 ([0]): One of the following options for identifying the URL of the external web service.
Endpoint URL. For example: 'http://YourServer/YourService'
Named credential URL, which contains the scheme callout, the name of the named credential, and optionally, an appended path. For example: 'callout:MyNamedCredential/some/path'
Element at index 1 ([1]): The SOAP action. For example: 'urn:dotnet.callouttest.soap.sforce.com/EchoString'
Element at index 2 ([2]): The request namespace. For example: 'http://doc.sample.com/docSample'
Element at index 3 ([3]): The request name. For example: 'EchoString'
From the anonymous window ( Developer console ), you can execute this short piece of code:
pattern myPattern = pattern.compile('(?msi)WebServiceCallout.invoke.*?\\(.+?\\)');
Tried to run the code via anonymous window, but it prompt me with 'No response from the server', I can run the soql and get some data from Query Editor, but not from anonymous windows, the first line of code gave me the prompt, tried different soql, same thing, need to dig into the code.
Thanks Alian, I think I got the idea.
Exactly you have understood the whole picture.
'No response from the server', ; perhaps you have too many classes and you overcome a governor limit.
I tested the following code with a lot of code (680 real classes) on our acceptance org and that works but that could be different on your org.
if (!apx.name.tolowercase().endswith('test')) { // because it is useless to scan the test classes
pattern myPattern2 = pattern.compile('(?msi)new.+?String.*?\\[.*?\\].*?\\{(.+?)\\}'); // scan the infoArray but that could be different on you org.
List<ApexClass> lapc = [select id,namespaceprefix,name,isvalid,body from apexclass LIMIT 100]; // for a try with just the first 100 classes
You could then retrieve the next 100 classes, 101 through 201, using the following query:
List<ApexClass> lapc = [select id,namespaceprefix,name,isvalid,body from apexclass LIMIT 100 OFFSET 100];
Thanks for the quick response, I figured out the cause is our windows security updates happened on the weekend.
I don’t know what blocks the server response, just tried to run the same code from outside of company’s network, it works, but got ‘No response from the server’ when I switch back to company’s network.
The code above is "minimalist" (+ zero installation) and not "handy" when you cannot get the result easily from the log with a lot of web services.
I know other techniques but they are even more technical and I am rarely a success witth them.
You have opened end points but that is not sufficient to get all the web service names.
The most appreciated solution would be a simple appexchange free application ( https://appexchange.salesforce.com/ (https://appexchange.salesforce.com/) )
It is easy to add a small form with a caller button and to get the result on screen in a basic textarea field ( + copy/paste) with the code above.
I will create a simple page and we will see if that works better for your org. I will make some tests before publishing it here.
Your question is interesting and I have the same need.
Alain
If you are allowed to create Visualforce pages and Apex classes, you can try this code.
Apex Class:
Visualforce Page: