Step 3a: Receive Salesforce Opportunity Notification into BizTalk Server
In this step, we start creating a BizTalk Server. We should first include the message schema for the opportunities notification message that we’ll get from Salesforce and then start creating an orchestration to process the message.
To include the Salesforce opportunities notification schema
Login to the Salesforce.com portal. On the Salesforce portal, click your login name at the top right corner of the page, and then click Setup.
In the left pane, under App Setup, expand Create, expand Workflow & Approvals, and then click Workflow Rules.
In the All Workflow Rules page, click the Closed Opportunity workflow that you created earlier.
In the Closed Opportunity workflow rule page, click NewOp1 outbound message workflow action.
In the NewOp1 outbound message workflow action page, right-click the link Click for WSDL, click Save target as, and then specify the location where you want to save the WSDL.
You must save the file with a .wsdl extension.
Create a BizTalk Server in Visual Studio. For this tutorial, let us name the project as BtsSalesforceIntegration.
Right-click the BizTalk Server project in the Solution Explorer, point to Add, and then click Add Generated Items.
In the Add Generated Items dialog box, click Consume WCF Service, and then click Add to launch the BizTalk WCF Service Consuming wizard. On the welcome page, click Next.
On the Metadata Source page, select the Metadata Files (WSDL and XSD) option, and then click Next.
On the Metadata Files page, click Add, and then navigate to the location where you saved the WSDL file downloaded from the Salesforce portal. Select the WSDL file and then click Next.
In the next page, set the namespace as NotificationService and then click Import. The wizard adds the schema files and an orchestration to the BizTalk Server project. The message schema for receiving opportunity notifications from Salesforce is NotificationService_soap_sforce_com_2005_09_outbound.xsd.
To create an orchestration to receive the notification message
After you complete the BizTalk WCF Service Consuming wizard, an orchestration (NotificationService.odx, in this example) is added to the BizTalk Server project.
Open the orchestration file and in the Orchestration view, add two new message variables. Name them NotificationMessage and NotificationAck. Set the message type for these message variables as follows:
Set NotificationMessage to NotificationService.NotificationService_soap_sforce_com_2005_09_outbound.notifications. This message variable represents the opportunity notification message received from Salesforce.
Set NotificationAck to NotificationService.NotificationService_soap_sforce_com_2005_09_outbound.notificationsResponse. This message variable represents the opportunity notification acknowledgement message sent back to Salesforce.
Add a receive shape to the orchestration. Set the following properties on the shape:
Set Activate to True.
Set Name to ReceiveNotificationMessage.
Set Message to NotificationMessage.
Add a Construct Message shape after the Receive shape. Name the message shape as ConstructNotificationResponse and set the Messages Constructed property to NotificationAck. As part of the construct message, we’ll also create a map to generate a notification acknowledgement message to be sent back to Salesforce.
Within the Construct Message shape, add a Transform shape. Double-click the Transform shape and in the Transform Configuration dialog box, select the New Map option.
Specify the map name as BtsSalesforceIntegration.MapNotificationResponse.
Set Source as NotificationMessage and Destination as NotificationAck.
Make sure the check box When I click OK, launch the BizTalk Mapper is selected.
In MapNotificationResponse.btm, we’ll create a notification response to be sent back to Salesforce. Every time Salesforce sends a notification, it expects an acknowledgement in return. The schema of the notification response message shows that the Ack element in the response is of type Boolean. So, in the map, you must drop a Value Mapping functoid and set its two input values (Condition and Result) to true. Click OK to save the functoid.
Connect the Value Mapping functoid to the Ack element in the destination schema.
In the orchestration, after the Construct Message shape, add a Send shape that will be used to send the acknowledgement back to Salesforce.
Set Name to SendNotificationAck.
Set Message to NotificationAck.
In the orchestration, add a port to receive Salesforce notification message and send the acknowledgement in response. In the Port Configuration wizard, select the following options:
Specify the port name as SalesforceNotificationPort.
Select the option to create a new port type.
Set Communication Pattern to Request-Response.
Set Port direction of communication to I’ll be receiving a request and sending a response and set Port binding to Specify later.
Connect the Request operation of port to the Receive shape (ReceiveNotificationMessage) and the Response operation of the port to the Send shape (SendNotificationAck). The following screenshot depicts the part of the orchestration that receives an opportunity notification from Salesforce and sends an acknowledgement back:
By now, we have set up the solution where an opportunity notification is received from Salesforce and an acknowledgement is sent back. In the subsequent topics, we’ll build on this solution to start processing the opportunity notification to get more details about the kind of sales opportunity available.