Currently I have a .asmx webservice for each salesforce object that sends an outbound message. For example AccountNotificationService.asmx and ContactNotificationService.asmx. Each Contact notification is consumed like so
[SOAPTraceExtensionAttribute]
public notificationsResponse notifications(notifications notifications1)
{
notificationsResponse response = null;
bool responseAck = true;
try
{
if (!object.ReferenceEquals(notifications1.Notification, null))
{
ContactNotification[] locations = notifications1.Notification;
for (int i = 0; i < locations.Length; i++)
{
ContactNotification notification = locations[i];
//Pull the contact data out
Contact contactObject = (Contact)notification.sObject;
if (!object.ReferenceEquals(contactObject, null))
{
Process(contactObject);
}
}
}
}
catch (Exception ex)
{
responseAck = false;
//TODO: add error logging
throw ex;
}
finally
{
//send the response.
response = new notificationsResponse();
response.Ack = responseAck;
}
return response;
}
and the same way for an Account notification. My question is, how can I create just a single webservice that can accept any SF soap message. deserialize the message and determine the type?
var type = notifications1.Notification.GetType();