2

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();

1 Answer 1

0

You can't do that using the standard workflow outbound messages. They require a separate endpoint. You could do it by creating a generic outbound call using APEX.

  1. Start by creating your generic webservice endpoint
  2. Then generate a WSDL for that webservice
  3. Have SFDC generate an APEX class from the WSDL
  4. Write APEX triggers on the desired objects that call the generated APEX code and do a callout. Don't forget to make them asynchronous (@future)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .