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
JD2010JD2010 

Custom Webservices Question

For you experts out there who have done a bunch with the webservices, I am curious. Is it possible for users to create their own, custom web service API methods in the Force.com platform utilizing Apex? For example, a webservices call is sent to the server, such as GetDate, which is an apex defined function (or perhaps a class) that returns, for example, a date? If so, where have I missed the information regarding it in the documentation (or perhaps on the forums)? I've looked around to no avail thus far.

 

Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
sdetweilsdetweil

Yes, an SFDC org customer can create apex classes that call web services.

 

three are two methods, depending on what you are trying to accomplish

 

I have an external server that provides support functions. I defined a web service there, using the Eclipse WTP WSDL editor.

 

I then created an APEX Class (setup->develop->apex->Class, push the Generate from Wsdl button (next to New),

load from your file system) tada.. some edting will be required to use @future due to the timing required.

 

then you use the same WSDL on the server side to create the java classes and extend as required.

 

if the service you want to connect to is provided by someone else, have them give you the WSDL.

 

you can also create an APEX class and have IT be the server. by defining the APEX class as a webservice type (for example)

 

 

    // A class to send back as an output 
    global class myOutputs{
        webservice String errorMessage;
        webservice Boolean success;
        webservice List<myInputs> inputs;
        webservice Id contactId;
    }

 

 
webservice
 static myOutputs myMethod(Id contactId, List<myInputs> inputs){

 

then u generate the WSDL for the external application to use..

 

Sam

All Answers

sdetweilsdetweil

Yes, an SFDC org customer can create apex classes that call web services.

 

three are two methods, depending on what you are trying to accomplish

 

I have an external server that provides support functions. I defined a web service there, using the Eclipse WTP WSDL editor.

 

I then created an APEX Class (setup->develop->apex->Class, push the Generate from Wsdl button (next to New),

load from your file system) tada.. some edting will be required to use @future due to the timing required.

 

then you use the same WSDL on the server side to create the java classes and extend as required.

 

if the service you want to connect to is provided by someone else, have them give you the WSDL.

 

you can also create an APEX class and have IT be the server. by defining the APEX class as a webservice type (for example)

 

 

    // A class to send back as an output 
    global class myOutputs{
        webservice String errorMessage;
        webservice Boolean success;
        webservice List<myInputs> inputs;
        webservice Id contactId;
    }

 

 
webservice
 static myOutputs myMethod(Id contactId, List<myInputs> inputs){

 

then u generate the WSDL for the external application to use..

 

Sam

This was selected as the best answer
JD2010JD2010

Great, that's what I was curious on. Ill have to dig a little deeper on the setting up of the WSDL and all that.