My client wants to send Account and Contact information from external system. For that reason, I have created one custom webservice class which can take any kind of data and based on the structure of data, I want to call respective classes.
IRequestInfo
global abstract class IRequestInfo {
}
IResponseInfo
global abstract class IResponseInfo {
webservice String result {get;set;}
}
There are AccountRequestInfo
and ContactRequestInfo
global classes which are extended from IResponseInfo
and those hold respective attributes like name, phone etc.
global class AccountRequestInfo extends IRequestInfo{
webservice String name {get;set;}
webservice String extenalId {get;set;}
}
My Main entry point webservice class
global class CustomWebserviceFacade {
webservice static List<IResponseInfo> process(List<IRequestInfo> dataMap){
if(dataMap instanceof List<AccountRequestInfo>)
{
System.debug('for Account related data parse request');
List<IResponseInfo> returnInfo = CustomAccountService.processData(dataMap);
return returnInfo;
}
else if(dataMap instanceof List<ContactRequestInfo>)
{
System.debug('for Contact related data parse request');
List<IResponseInfo> returnInfo = CustomContactService.processData(dataMap);
return returnInfo;
}
return null;
}
}
Issue I am facing is, when I generate WSDL and try to send parameters to the process
method of type AccountRequestInfo
or ContactRequestInfo
, those are not recognizable. Since those info classes are not in my main webservice class, though those are global classes.
So, how I can distribute the classes to external system so that all my relevant info classes can be recognized.
Is that Info classes should exist in the main webservice class? If so, it might defeat the design.
If I write test class and call the process method internally, it works absolutely fine.
Please suggest.
AccountRequestInfo
andContactRequestInfo
defined right within your web service class. WSDL as a document should contain the definition of the data types which any external client will utilize as a contract to invoke the web services exposed. If the generated WSDL doesn't have the definition for the data type that can be used, the client won't be able to construct it then.IFoo
,IBar
, etc are interfaces. For abstract classes we typically drop the prefix.