[SalesForce] Getting objects (complex type) as input parameters in webservice method (using SOAP) is possible or not

global class TestWebService {
    webService static String sayHello(String a, String b)  
    {  
            return 'Hello, '+a+' '+b+'!!';
    }  
}

In the above webservice method it accepts two input parameters (simple type String here). What i need is an object such as a student object or an employee object as the input parameter for the webservice method like the given below,

global class TestWebService {
    webService static String sayHello(Employee emp)  
    {  
            //---code to handle the emp object goes here----
            return 'success'; 

    }  
}

The above method would be called from SAP system. My question is, passing object (complex type) as an input in the webservice method is possible or not? the webservice is created in Salesforce and expose to external interfaces. Any ideas?

Thanks,
Baskaran

Best Answer

You can use any object not explicitly mentioned on the Considerations for Using the WebService Keyword page. This includes global classes and any SObjectType configurations in your organization. The WSDL generator will create the correct syntax for you to use for the call, but you may also want to import an Enterprise WSDL if you want strong bindings to the objects and fields your organization has available. Otherwise, you can use the Partner WDSL's generic SObject constructors to form valid message parameters.

Related Topic