1

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!

user692942
  • 16,398
  • 7
  • 76
  • 175
mholberger
  • 337
  • 3
  • 14
  • I have simple test ASP files executing on my server, I just cant figure out how to store a SOAP message that is sent to a static URL. – mholberger May 13 '16 at 15:59
  • The SOAP by design is done by 'post', so it should be fairly easy to call into an ASP vb script. Is there a name or some sort of ID that I can call using Request.Form()? Im looking but I dont see anything familiar I can call. – mholberger May 13 '16 at 18:56
  • Ok so there is a separate API called the client alert API that allows you to send calls to the notification server and receive notifications. this makes is so you dont have to use up all of your 5000 daily call limit for the trading API by constantly calling GetOrders. Its really odd though, that in the documentation for working with notifications they make no mention at all of this?? is there anyone out there who has any experience with ebay api? – mholberger May 14 '16 at 03:10
  • What are you using ASP.Net or Classic ASP? The two are quite different. – user692942 May 16 '16 at 09:01
  • classic ASP. i just need to grab whatever SOAP xml that ebay posts and output it to a text file. – mholberger May 16 '16 at 14:28
  • Tbh, Classic ASP isn't going to be ideal for a web service scenario. But it is fine as a endpoint for say an API that POST to a Classic ASP page for example, if the API supports pushing information to an endpoint URL. – user692942 May 16 '16 at 14:33

2 Answers2

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

Community
  • 1
  • 1
user692942
  • 16,398
  • 7
  • 76
  • 175
  • thank you this is helpful. the response does come with a token that I can use to verify the message to prevent spoofing. – mholberger May 16 '16 at 16:55
  • I have everything working except the part that checks for the SOAPACTION header. When I leave that If statement in it gives me server error 500. Otherwise i have the bin to string and text file output all working. – mholberger May 16 '16 at 21:32
  • @mholberger It is just pseudo coded I didn't have chance to test it just based off similar processes I've written before to be consumed as an endpoint by an API. If you provide a bit more information about the 500 error I might be able to help, for example which line causes the error? – user692942 May 16 '16 at 21:48
0

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:\inetpub\wwwroot\ASPtest\notifications.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
%>
mholberger
  • 337
  • 3
  • 14