Web Services
  Home arrow Web Services arrow Page 3 - Automated Billing and Faxing for the Web
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WEB SERVICES

Automated Billing and Faxing for the Web
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2007-08-23

    Table of Contents:
  • Automated Billing and Faxing for the Web
  • Starting the Transaction
  • Getting a Transaction Notification
  • Getting a Transaction Notification continued
  • Responding to the Transaction

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Automated Billing and Faxing for the Web - Getting a Transaction Notification


    (Page 3 of 5 )

    When an order is processed, PayPal generates a notification that is then posted to the URL specified in the form as the hidden field notify_url. This is an example of a web service that relies on ordinary HTTP—no fancy SOAP or other RPC underpinnings. 

    Using a simple HTTP request/response is perhaps the most basic, universal real world web service. It works with virtually every programming language and requires no special configuration to use. It’s a classic case of the simple solution being the best solution.

    Example 6-2 shows the JSP used to receive notifications from the PayPal server.

    Example 6-2. Notification JSP

    <%@ page contentType="text/html; charset=iso-8859-1"
    language="java" import="com.cascadetg.ch06.*" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/ xhtml1/DTD/xhtml1-transitional.dtd">
    <%
    new PayPalReciept().handleRequest(request, response);
    response.setStatus(200);
    %>

    The lineresponse.setStatus(200)notifies PayPal that the notification has successfully been handled. By default, PayPal resends the notification until it gets a status code of200back, indicating that the transmission was successful. Disabling this line or substituting a different response code is an easy way to generate additional test load for your server without having to manually enter a lot of transactions.

    The bulk of the work for this application is handled by supporting Java classes, as shown in Figure 6-5.

    The first class, shown in Example 6-3, exposes one main method,handleRequest(), to the JSP page. In thehandleRequest()method, the first thing to be done is verify that the data sent by PayPal is correct with theverifyRequest()method. TheverifyRequest() method retrieves the parameters sent by PayPal and then posts


    Figure 6-5.  PayPal and Fax classes

    them back to PayPal via an HTTPS connection, with an additional parameter added (cmd=_notify-validate).

    More Web Services Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Real World Web Services," published by...
     

    Buy this book now. This article is excerpted from chapter six of the book Real World Web Services, written by Will Iverson (O'Reilly; ISBN: 059600642X). Check it out today at your favorite bookstore. Buy this book now.

    WEB SERVICES ARTICLES

    - Safety, Idempotence, and the Resource-Orient...
    - The Resource-Oriented Architecture in Action
    - Features of the Resource-Oriented Architectu...
    - The Resource-Oriented Architecture
    - Getting Started with Flex
    - Automated Billing and Faxing for the Web
    - An Introduction to Web Services
    - The Foundations of Web Services: From Novice...
    - Web Services Reengineering: Finishing Touches
    - Fault Handling with Web Services
    - Flow and Web Services
    - Process Lifecycles and Web Services
    - Business Processes and Web Services
    - Orchestrating Web Services
    - Notifications and Resources in the WS-Resour...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek