Skip to main content
February 24, 2009
Answered

Simple Soap Listener

  • February 24, 2009
  • 1 reply
  • 1815 views
Hey Guys,
I have an external peice of software that can send updates via SOAP messages. I would like to build the endpoint in Cold Fusion. I imagine this will be done by creating an event gateway. For this example, I would just like to create a tag that takes all the SOAP it gets passed and write it to a log file. I am not sure how to being creating an event gateway, I am familiar with web services, just not this particular aspect of them. Please let me know if you have any useful tutorials or even sample code would be great. Thank you.
This topic has been closed for replies.
Correct answer
Hey Guys.
I figured it out. For anyone else who is trying to use outbound messaging with Salesforce and Cold Fusion, this is how I did it. Turns out all you need is a page that does whatever you want it to do, and returns a simple soap envelope that says it completed. I almost feel like I should write a tutorial page or something, but maybe I'll do that later.

Since your getting SOAP data from Salesforce, use
<cfset SoapData = GetHttpRequestData()>

That saves everything you need to a variable. Then Parse the XML with
<CFSet xmlDoc = XMLParse(SoapData.Content)>

Now you have a nice package to read this crap with. You can do whatever you would want to with your XML data. I decided to read just a few needed pieces of info.

<cfset SFDATA.CCID = xmlDoc.Envelope.Body.Notifications.Notification.sObject.Child_Campaign__c.XmlText>
<cfset SFDATA.ID = xmlDoc.Envelope.Body.Notifications.Notification.sObject.ID.XmlText>
<cfset SFDATA.RID = xmlDoc.Envelope.Body.Notifications.Notification.sObject.Respondent__c.XmlText>
<cfset SFDATA.MCID = xmlDoc.Envelope.Body.Notifications.Notification.sObject.Master_Campaign__c.XmlText>

The other thing to note, for the trigger to work properly, Salesforce expects to receive a valid SOAP packet pack. Something that looks like

<?xml version = "1.0" encoding = "utf-8"?>
<soapenv:Envelope xmlns:soapenv=" http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<notifications xmlns=" http://soap.sforce.com/2005/09/outbound">
<Ack>true</Ack>
</notifications>
</soapenv:Body>

From what I can tell it must be the very first, and probably only thing returned. I put that at the top of my page, and wrapped the rest of my code in CFSilent to make sure nothing else was generated. Here is my full sample.

I hope this helps somebody out there. Took me a while to figure out.
</soapenv:Envelope>

1 reply

February 24, 2009
Here is an article that has pretty much exactly what i want to do, in PHP.

http://www.mikesimonds.com/using-salesforce-outbound-soap-messages-php-t95.html

Basically Salesforce can send a SOAP message when something happens. I want cold fusion to catch that soap message and save it.
Correct answer
February 24, 2009
Hey Guys.
I figured it out. For anyone else who is trying to use outbound messaging with Salesforce and Cold Fusion, this is how I did it. Turns out all you need is a page that does whatever you want it to do, and returns a simple soap envelope that says it completed. I almost feel like I should write a tutorial page or something, but maybe I'll do that later.

Since your getting SOAP data from Salesforce, use
<cfset SoapData = GetHttpRequestData()>

That saves everything you need to a variable. Then Parse the XML with
<CFSet xmlDoc = XMLParse(SoapData.Content)>

Now you have a nice package to read this crap with. You can do whatever you would want to with your XML data. I decided to read just a few needed pieces of info.

<cfset SFDATA.CCID = xmlDoc.Envelope.Body.Notifications.Notification.sObject.Child_Campaign__c.XmlText>
<cfset SFDATA.ID = xmlDoc.Envelope.Body.Notifications.Notification.sObject.ID.XmlText>
<cfset SFDATA.RID = xmlDoc.Envelope.Body.Notifications.Notification.sObject.Respondent__c.XmlText>
<cfset SFDATA.MCID = xmlDoc.Envelope.Body.Notifications.Notification.sObject.Master_Campaign__c.XmlText>

The other thing to note, for the trigger to work properly, Salesforce expects to receive a valid SOAP packet pack. Something that looks like

<?xml version = "1.0" encoding = "utf-8"?>
<soapenv:Envelope xmlns:soapenv=" http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<notifications xmlns=" http://soap.sforce.com/2005/09/outbound">
<Ack>true</Ack>
</notifications>
</soapenv:Body>

From what I can tell it must be the very first, and probably only thing returned. I put that at the top of my page, and wrapped the rest of my code in CFSilent to make sure nothing else was generated. Here is my full sample.

I hope this helps somebody out there. Took me a while to figure out.
</soapenv:Envelope>