skip to Main Content

I am trying to receive ebay api transaction notifications into an ASP hosted on a web server. The notifications are sent as SOAP messages and can be sent to a URL with a query string. Notifications must be responded to with HTTP 200 OK. I would like the notification to land inside a variable so that I can parse it and send it on to the next part of the system.

http://developer.ebay.com/DevZone/guides/ebayfeatures/Notifications/Notifications.html#ReceivingPlatformNotifications

In the documentation they mention that this is possible, but the sample they give goes the route of subscribing to an email server. This ASP would not necessarily need to make SOAP requests, just accept SOAP messages from the ebay servers.

I am studying ASP, SOAP, and query strings, but a little guidance would be truly appreciated. Thanks!

2

Answers


  1. Chosen as BEST ANSWER

    This is what i have so far in my notifications.asp. When I try to send it a basic SOAP post through Postman nothing is happening. Does this look like it should work?

    I tested this without the If statements checking for SOAP headers, and I posted just regular string data and it works. So the binary to string conversion and output to file is all good. Now I just need to test it with actual ebay api notifications. ;-)

    <%
    Function BytesToStr(bytes)
        Dim Stream
        Set Stream = Server.CreateObject("Adodb.Stream")
        Stream.Type = 1 'adTypeBinary
        Stream.Open
        Stream.Write bytes
        Stream.Position = 0
        Stream.Type = 2 'adTypeText
        Stream.Charset = "iso-8859-1"
        BytesToStr = Stream.ReadText
        Stream.Close
    Set Stream = Nothing
    End Function
    
    
    Dim isPost: isPost = (UCase(Request.ServerVariables("REQUEST_METHOD") & "") = "POST")
    Dim hasSoapAction
    
    'Is it a HTTP POST?
    If isPost Then
    'Do we have a SOAPACTION header?
        hasSoapAction = (Len(Request.ServerVariables("HEADER_SOAPACTION") & "") > 0)
        If hasSoapAction Then
        'Process the notification here.
        'Use Request.BinaryRead to read the SOAP
    
            If Request.TotalBytes > 0 Then
                Dim lngBytesCount, text
                lngBytesCount = Request.TotalBytes
                text = BytesToStr(Request.BinaryRead(lngBytesCount))
    
                dim fs, tfile
                set fs=Server.CreateObject("Scripting.FileSystemObject")
                set tfile=fs.CreateTextFile("C:inetpubwwwrootASPtestnotifications.txt")
                tfile.WriteLine(text)
                tfile.Close
                set tfile=nothing
                set fs=nothing  
            End If  
    
        End If
        'Let eBay know we have received and processing the message.
        Response.Status = "200 OK"
    Else
    'Return method not allowed
    Response.Status = "405 Method Not Allowed"
    End If
    Response.End
    %>
    

  2. This should be pretty straight forward, your Classic ASP page becomes the endpoint for the eBay Notification API (as long as you have configured it to send notifications and what URL to send them to).

    You should be able to test this with a simple Classic ASP page

    <%
    Dim isPost: isPost = (UCase(Request.ServerVariables("REQUEST_METHOD") & "") = "POST")
    Dim hasSoapAction
    
    'Is it a HTTP POST?
    If isPost Then
      'Do we have a SOAPACTION header (check both because 
      'it can be either HTTP_ or HEADER_ depending on IIS version)?
      hasSoapAction = ( _
        Len(Request.ServerVariables("HEADER_SOAPACTION") & "") > 0 Or _
        Len(Request.ServerVariables("HTTP_SOAPACTION") & "") > 0 _
      )
      If hasSoapAction Then
        'Process the notification here.
        'Use Request.BinaryRead to read the SOAP
      End If
      'Let eBay know we have received and processing the message.
      Response.Status = "200 OK"
    Else
      'Return method not allowed
      Response.Status = "405 Method Not Allowed"
    End If
    Response.End
    %>
    

    You might also want to check REMOTE_HOST to make sure that you are only getting sent messages for the expected source (this isn’t bulletproof though as the information can be spoofed).


    Useful Links

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search