function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ShadowlessKickShadowlessKick 

Outbound Message - Call Back

Am implementing outbound messaging in a .Net web application.  Am sending in the ID only.  Receive an acknowledgment back and everything is working to that point. 

The next step is to to re-access Salesforce.  Multiple posts say that with the session id passed through the outbound message you can get back to Salesrooms without logging in again.

 

Does anyone have an example of code for that?  Have been trying to use the SforceService but it appears that you MUST log in with credentails. 

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

svc.url = urlFromMessage

svc.sessionHeader = new SessionHeader()

svc.sessionHeader.sessionId = sessionIdFromMsg

 

do something with svc.

All Answers

SuperfellSuperfell

svc.url = urlFromMessage

svc.sessionHeader = new SessionHeader()

svc.sessionHeader.sessionId = sessionIdFromMsg

 

do something with svc.

This was selected as the best answer
ShadowlessKickShadowlessKick

 

Thank you for your help.  I was under the impression that I had to use the outbound message notification service.  In the end it was the SForceService.  This is how the .net code looks in case someone else is wondering.   

 

Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Diagnostics
Imports System.Web.Services
Imports AccountNotification

<WebService(Namespace:="https://test.com/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class AccountNotificationServiceImpl
    Inherits System.Web.Services.WebService
    Implements AccountNotification.INotificationBinding

    Dim TheAccountId As String
    
#Region "INotificationBinding Members"

    Private Property binding As SForce.SforceService

    <WebMethod()> _
    Public Function notifications(ByVal notifications1 As AccountNotification.notifications) As AccountNotification.notificationsResponse _
        Implements AccountNotification.INotificationBinding.notifications

        Dim accounts() As AccountNotification.AccountNotification = notifications1.Notification
        Dim i As Integer = 0
        Do While (i < accounts.Length)
            Dim notification As AccountNotification.AccountNotification = accounts(i)
            Dim account As AccountNotification.Account = CType(notification.sObject, AccountNotification.Account)
            TheAccountId = account.Id.ToString
            i = (i + 1)
        Loop
        'Now, set the response.
        Dim response As AccountNotification.notificationsResponse = New AccountNotification.notificationsResponse
        
        response.Ack = True

	'Now query back to SFDC for other information
        Dim DunsNumber As String = "Looking for any value"
        Dim TheAcctQueryResult As SForce.QueryResult = Nothing
        Try
            binding = New SForce.SforceService
            If (Not (binding) Is Nothing) Then
                If (Not (notifications1) Is Nothing) Then
                    If (Not (notifications1.SessionId) Is Nothing) Then
                        If (Not (notifications1.EnterpriseUrl) Is Nothing) Then
                            binding.Url = notifications1.EnterpriseUrl
                            binding.SessionHeaderValue = New SForce.SessionHeader()
                            If (Not (binding.SessionHeaderValue) Is Nothing) Then
                                binding.SessionHeaderValue.sessionId = notifications1.SessionId
                            End If
                        End If
                    End If
                End If
            End If
            binding.QueryOptionsValue = New SForce.QueryOptions()
                binding.QueryOptionsValue.batchSize = 1
                binding.QueryOptionsValue.batchSizeSpecified = True
                TheAcctQueryResult = binding.query("Select id, D_U_N_S__c from account where id = '" & TheAccountId.ToString & "'")
                If TheAcctQueryResult.size > 0 Then
                    For x As Integer = 0 To TheAcctQueryResult.records.Length - 1
                        Dim TheAccount As SForce.Account = DirectCast(TheAcctQueryResult.records(x), SForce.Account)
                        DunsNumber = TheAccount.D_U_N_S__c.ToString
                    Next
                End If
            Catch
            Finally
            End Try
   
        Return response
    End Function

#End Region
End Class

 

Thank you for your help.