3
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

1
  • I'm pretty sure that's fine. Go to the Apex Class, generate the WSDL and it will contain the appropriate definitions. – Matt and Neil Feb 21 '14 at 12:28
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.