Docstoc

Analysis of Stock Marketing with SOAP service using Python

Document Sample
Analysis of Stock Marketing with SOAP service using Python Powered By Docstoc
					                                                      (IJCSIS) International Journal of Computer Science and Information Security,
                                                      Vol. 10, No. 3, March 2012



   Analysis of Stock Marketing with SOAP service using
                         Python
                         P.Asha1                                                            Dr.T.Jebarajan2
         1                                                                    2
      Research Scholar,Computer Science and                                       Principal, Kings College of Engineering,
  Engineering Department, Sathyabama University,                                         Chennai, Tamilnadu,India.
             Chennai,Tamilnadu,India.                                                    drtjebarajan@gmail.com
          ashapandian225@gmail.com

                                                         Kathiresan3
                                     3
                                         Technical Lead Consultant, Motorola Solutions,
                                                  Bangalore, Karnataka, India
                                                     kathir.it@gmail.com

Abstract -      SOAP is a simple XML-based protocol                  services coordinating some activity. Some means of
specification to let applications exchange information               connecting services to each other is needed.
over HTTP. SOAP describes envelope and message                                A web service is the connection technology
formats, and has a basic request/response handshake                  of service-oriented architectures.
protocol. A SOAP message could be sent to a web-service-                  • “A Web Service (WS) is a software system
enabled web site such as a real-estate price database, with
the parameters needed for a search. The site would then                       designed to support interoperable machine-
return an XML formatted document with the resulting                           to-machine interaction over a network.”
data, e.g., prices, location, features. With the data being               • Usually a WS provides the API (Application
returned in a standardized machine-parseable format, it                       Programming Interface).
can then be integrated directly into a third party web site                   Web services essentially use XML to create
or application. SOAPpy provides tools for building SOAP              a robust connection.
clients and servers. SOAPpy is very simple to use and that
fully supports dynamic interaction between clients and
servers.                                                             A. SOA Interaction Pattern
Keywords— Service Oriented Architecture, SOAP, Web
Service, SOAPpy, XML.
                                                                          •        A service provider creates a service for
                                                                                   interaction and exposes the service's
                   I.   INTRODUCTION
                                                                                   description for the consumers with the
   An architectural style is a coordinated set of                                  necessary message format and transport
architectural    constraints   that     restricts the                              bindings.
roles/features of architectural elements and the
allowed relationships among those elements within
any architecture that conforms to that style.
   There are different Software Architecture Styles:

             •   Data Oriented Architecture
             •   Hierarchical Architecture
             •   Call and Return Architecture
             •   Interaction Process Architecture
             •   Service Oriented Architecture
             •   Space based Architecture


   II.       SERVICE ORIENTED ARCHITECTURE
          A service is a function that is well-defined,
self-contained, and does not depend on the context or
state of other services. A service-oriented architecture
is a collection of services. These services
communicate with each other which involve either                        Figure 1. Service Oriented Architecture model implemented
simple data passing or it could involve two or more                                         by XML Web Services




                                                               98                                  http://sites.google.com/site/ijcsis/
                                                                                                   ISSN 1947-5500
                                                    (IJCSIS) International Journal of Computer Science and Information Security,
                                                    Vol. 10, No. 3, March 2012


    •   The service provider may decide to register                  III.   SIMPLE OBJECT ACCESS PROTOCOL
        this service and its description with a
        registry of choice.                                                 SOAP (Simple Object Access Protocol) is
    •   The service consumer can discover a service                required for application development to allow
        from a registry or directly from the service               Internet communication between programs. SOAP
        provider and can start sending messages in a               provides a way to communicate between applications
        well-defined XML format that both the                      running on different operating systems, with different
        consumer and service can consume.                          technologies and programming languages.

B. SOA Realization (Two ways)                                      A. SOAP Processing Model and Message Format
   SOA can be realized by the following ways:
                                                                   SOAP sender - A SOAP node that transmits a SOAP
    •   XML - SOAP Based Web Services                              message.
    •   ReSTful Web services                                       SOAP receiver - A SOAP node that accepts a SOAP
                                                                   message.
                                                                   SOAP message path - The set of SOAP nodes
    Earlier, the message exchange between a
                                                                   through which a single SOAP message passes.
consumer and producer was by using a common, well                  Initial SOAP sender (Originator) - The SOAP sender
understandable, and interoperable data model,                      that originates a SOAP message at the starting point
HTML/XHTML.                                                        of a SOAP message path.
                                                                   SOAP intermediary - A SOAP intermediary is both a
                                                                   SOAP receiver and a SOAP sender and is targetable
                                                                   from within a SOAP message. It processes the SOAP
                                                                   header blocks targeted at it and acts to forward a
                                                                   SOAP message towards an ultimate SOAP receiver.
                                                                   Ultimate SOAP receiver - The SOAP receiver that is
                                                                   a final destination of a SOAP message. It is
                 Figure 2. WebSites (1992)                         responsible for processing the contents of the SOAP
                                                                   body and any SOAP header blocks targeted at it.

         Later on, when the interaction pattern
becomes complex, such as business-to-business, the                 B. SOAPpy
above Web architecture model needs more polished                           SOAPpy is a SOAP-1.1 library for Python
message exchange patterns to adapt to any user agent               which uses WSDL and SDL documents to discover
and/or applications of choice. The Web service                     SOAP-based service APIs. It also includes an XML
architecture extends the above interaction pattern                 Schema parser which can parse a subset of the XML
further by adding the power and expressiveness of                  Schema standard.
XML.
                                                                   Features of SOAPpy
                                                                    • Automatic stateful SOAP server support
                                                                    • SOAP 1.0
                                                                    • WSDL client/server support
                                                                    • SSL clients/servers (based on OpenSSL)
                                                                    • General SOAP Parser/Builder based on sax.xml
                                                                    • SOAP for RPC client/server code
            Figure 3. WS - * Web Services (later)
                                                                                      IV.    CASE STUDY

         The message exchange centered on XML
                                                                          Here, we try to develop a Stock Market
and the interaction pattern have evolved to an any-to-             SOAP web service to get today’s sensex value from
any scenario. This flexible interaction pattern using              SOAP server.
XML messages as the core data format increases the
value of SOAs. This produces the interaction                       Steps:
request–response patterns, asynchronously, for better
interoperability between consumers and any of its                  1. Develop a Server function stkmarket in Python to
producers. This is a very loosely coupled system.                     calculate today's sensex value:


                                                             99                                http://sites.google.com/site/ijcsis/
                                                                                               ISSN 1947-5500
                                                (IJCSIS) International Journal of Computer Science and Information Security,
                                                Vol. 10, No. 3, March 2012


   a. Store yesterday's total market capitalization of         'hindalco':28296.31,
      30 companies in yst_totmktcap and yesterday's            'sunpharma':50174.82,
      sensex value in yst_sensex.                              'coalindia':240400.66,
                                                               'wipro':85298.49, 'cipla':55534.05,
   b. Get current market capitalization of 30                  'infy':136488.33, 'tcs':189310.17,
      companies in a dictionary.                               'tatamotors':50490.38,
   c. Add current market capitalization of 30                  'tatastl':46622.40
      companies to find current total market                   }
      capitalization (totmktcap).                              totmktcap   =   sum([i  for   i   in
   d. Find today's sensex value using the formula:             mktcap.values()])
      sensex = yst_sensex * totmktcap /                        sensex = yst_sensex * totmktcap /
                                                               yst_totmktcap
      yst_totmktcap
                                                               str   =    'UP'   if   ((sensex                               -
   e. Find the difference of sensex values                     yst_sensex) > 0) else 'DOWN'
      yst_sensex and sensex to show Market is UP
      or DOWN.                                                 res = "%s %d (%d %s)" %                           ('Today
                                                               sensex value is', sensex,
   f. Return the result string with today’s sensex
      value and market status.                                 sensex - yst_sensex, str)
                                                               return res
2. Create an object for SOAPServer to listen on
   "localhost" and port number 8080.                           server=
3. Register the Server function stkmarket in                   SOAPpy.SOAPServer(("localhost",
   SOAPServer.                                                 8080))
                                                               server.registerFunction(stkmarket)
4. Start the Stock Marker Web Service by listening             print 'Stock Market SOAP Server is
   with the SOAPServer object.                                 listening...'
5. Develop a Stock Market Client in Python to                  server.serve_forever()
   utilize the Stock Market Web Service:
   a. Create an object for SOAPProxy with                      2) Stock Market SOAP Client - soapclient.py
       http://localhost:8080/
   b. Enable debug messages to print the SOAP                  # soapclient.py
       request and response messages in the console.           import SOAPpy
                                                               server                             =
   c. Connect to the Stock Market Server and utilize           SOAPpy.SOAPProxy("http://localhost:
       the stkmarket webservice.                               8080/")
6. Display today’s sensex value and market status in           server.config.debug = 1
   the Client.                                                 print 'Stock Market SOAP Client is
                                                               connecting...'
                                                               print server.stkmarket()
1) Stock Market SOAP Server - soapserver.py
# soapserver.py                                                                      V.    RESULTS
import SOAPpy
def stkmarket():
yst_totmktcap = 2846906.42                                     OUTPUT
yst_sensex = 16990.18
                                                               In build.
#market   capitalization    for   30                           Outgoing        HTTP         headers
companies                                                      ***********************************
mktcap ={                                                      POST / HTTP/1.0
'mnm':18189.9, ’dlf':34070.83,                                 Host: localhost:8080
'itc':154745.53, 'hdfc':97137.93,                              User-agent:      SOAPpy       0.12.4
'jaipra':93983.21,                                             (http://pywebsvcs.sf.net)
'bajajaut':41301.80,'maruti':34895.                            Content-type:text/xml;charset=UTF-8
76,'ongc':244857.84,                                           Content-length: 348
'bhel':84760.39,                                               SOAPAction: "stkmarket"
'hdfcbank':108904.34,                                          ***********************************
'sbi':141640.87, 'hul':70719.84,                               OutgoingSOAP
'heromotoco':37054.34,                                         ***********************************
'bharatiatel':154597.04,                                       <?xml version="1.0" encoding="UTF-
'ntpc':139636.87,                                              8"?>
'jindalstell':48467.84,                                        <SOAP-ENV:Envelope             SOAP-
'icicibank':108414.38,                                         ENV:encodingStyle="http://schemas.x
'lnt':98332.13,                                                mlsoap.org/soap/encoding/"
'sterliteind':45364.79,'tatapower':
28010.89, 'ril':250612.63,


                                                         100                               http://sites.google.com/site/ijcsis/
                                                                                           ISSN 1947-5500
                                (IJCSIS) International Journal of Computer Science and Information Security,
                                Vol. 10, No. 3, March 2012

xmlns:SOAP-
ENC=http://schemas.xmlsoap.org/soap            xmlns:xsi="http://www.w3.org/1999/X
/encoding/xmlns:SOAP-                          MLSchema-instance"
ENV="http://schemas.xmlsoap.org/soa
p/envelope/">                                  xmlns:SOAP-
<SOAP-ENV:Body>                                ENV="http://schemas.xmlsoap.org/soa
<stkmarket SOAP-ENC:root="1">                  p/envelope/"
</stkmarket>
</SOAP-ENV:Body>                               xmlns:xsd=http://www.w3.org/1999/XM
</SOAP-ENV:Envelope>                           LSchema >
*************
code= 200    msg= OK headers=                  <SOAP-ENV:Body>
Server:<a                                      <stkmarketResponseSOAP-
href="http://pywebsvcs.sf.net">                ENC:root="1">
SOAPpy 0.12.4</a> (Python 2.7.1)               <Result xsi:type="xsd:string">Today
Date: Wed, 10 Aug 2011 11:09:10 GMT            sensex   value    is    17416   (426
Content-type:text/xml;charset=UTF-8            UP)</Result>
Content-length: 543                            </stkmarketResponse>
content-type=text/xml;                         </SOAP-ENV:Body>
charset=UTF-8                                  </SOAP-ENV:Envelope>
data=       <?xml      version="1.0"           ***********************************
encoding="UTF-8"?>                             Today sensex value is 17416 (426 Up)
<SOAP-ENV:EnvelopeSOAP-
ENV:encodingStyle="http://schemas.x
mlsoap.org/soap/encoding/"                              Hence simulation of SOAP messages for
xmlns:SOAP-                                    stock market sensex calculation is made.
ENC="http://schemas.xmlsoap.org/soa                     Client asks server about today's sensex
p/encoding/"                                   value. In server, we have a dictionary of key-value
xmlns:xsi="http://www.w3.org/1999/X            pairs (company and their market capitalization
MLSchema-instance"
xmlns:SOAP-                                    value). Based on these values the sensex is
ENV="http://schemas.xmlsoap.org/soa            calculated. The calculated sensex value is returned
p/envelope/"                                   back to the client. All the communication happens as
                                               a SOAP message. Though we are doing RPC using
xmlns:xsd=http://www.w3.org/1999/XM            python, the python SOAP library (SOAPpy) makes
LSchema >                                      this RPC with SOAP messages.
<SOAP-ENV:Body>
<stkmarketResponseSOAP-                                 At server side, one python function which is
ENC:root="1">                                  registered in SOAPpy server - these provides as the
<Result xsi:type="xsd:string">                 web service description and publish. At client side,
Today sensex value is 17416                    the SOAPpy proxy client invokes the server function
(426 UP)</Result>                              (as a RPC call) - this simulate the discovery of web
</stkmarketResponse>                           service and the message in between the entities are
</SOAP-ENV:Body>                               send as a SOAP envelopes with header and body
</SOAP-ENV:Envelope>
                                               blocks.
Incoming        HTTP         headers
***********************************
HTTP/1.? 200 OK                                                   VI.    CONCLUSION
Server:<a
href="http://pywebsvcs.sf.net">SOAP
py 0.12.4</a> (Python 2.7.1)                            A Stock Market SOAP web service has been
Date: Wed, 10 Aug 2011 11:09:10 GMT            developed to get today’s sensex value from SOAP
Content-type:text/xml;charset=UTF-8            server and the results were produced. Simulation of
Content-length: 543                            Web service (without WSDL) is done and not a form
**********************************             of registration in UDDI is made. Moreover there is
Incoming                        SOAP
***********************************            no real time service description, publish and
<?xmlversion="1.0"encoding="UTF-               discovery, everything is taken care of by SOAPpy.
8"?>
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle=                                                 REFERENCES
"http://schemas.xmlsoap.org/soap/en
coding/"
xmlns:SOAP-                                    [1] D. Braga, A. Campi, S. Ceri, M. Klemettinen, PL.
ENC="http://schemas.xmlsoap.org/soa                Lanzi,“Mining Association Rules from XML Data”, in
p/encoding/"                                       Proceedings of DEXA 2002 (DaWaK), LNCS 2454,
                                                   Aixen- Provence,France, Sep. 2002, pp. 21-30.



                                         101                               http://sites.google.com/site/ijcsis/
                                                                           ISSN 1947-5500
                                                          (IJCSIS) International Journal of Computer Science and Information Security,
                                                          Vol. 10, No. 3, March 2012


[2] Potts, M. Find Bind and Execute: Requirements forWeb
    Service Lookup and Discovery..
    www.talkingblocks.com/resources.htm#,
    accessed January 2003.

[3] Mohammed J. Zaki, Charu C. Aggarwa, “XRules: An
    Effective Structural Classifier for XML Data”, Rensselaer
    Polytechnic Institute.

[4] http://www.rediff.com/money/2000/apr/26sspe.htm

[5] http://www.informit.com/articles/article.aspx?p=336265

[6] Locad.com: Web Services Tutorial with Python.
     <http://www.lokad.com/web-services-time-seriesforecasting-
    tutorial-python.ashx>, January 2, 2008.

[7] World Wide Web Consortium (W3C): http://www.w3.org

[8] Joukl, Holger: Interoperable WSDL/SOAP web services
    introduction: Python ZSI, Excel XP, gSOAPC/C++ &
     ApplixSS).http://pywebsvcs.sourceforge.net/holger.pdf>.
    July 22, 2005.

[9] Boverhof, Joshua; Moad, Charles: ZSI: The Zolera Soap
     InfrastructureUser´s Guide.
     <http://downloads.sourceforge.net/pywebsvcs/ZSI-2.1-
      a1.tar.gz>, Release 2.1.0, November 01, 2007.

[10] WebServices.org:http://www.webservices.org




                                                                   102                               http://sites.google.com/site/ijcsis/
                                                                                                     ISSN 1947-5500

				
DOCUMENT INFO
Description: International Journal of Computer Science and Information Security (IJCSIS) provide a forum for publishing empirical results relevant to both researchers and practitioners, and also promotes the publication of industry-relevant research, to address the significant gap between research and practice. Being a fully open access scholarly journal, original research works and review articles are published in all areas of the computer science including emerging topics like cloud computing, software development etc. It continues promote insight and understanding of the state of the art and trends in technology. To a large extent, the credit for high quality, visibility and recognition of the journal goes to the editorial board and the technical review committee. Authors are solicited to contribute to the journal by submitting articles that illustrate research results, projects, surveying works and industrial experiences. The topics covered by this journal are diversed. (See monthly Call for Papers) For complete details about IJCSIS archives publications, abstracting/indexing, editorial board and other important information, please refer to IJCSIS homepage. IJCSIS appreciates all the insights and advice from authors/readers and reviewers. Indexed by the following International Agencies and institutions: EI, Scopus, DBLP, DOI, ProQuest, ISI Thomson Reuters. Average acceptance for the period January-March 2012 is 31%. We look forward to receive your valuable papers. If you have further questions please do not hesitate to contact us at ijcsiseditor@gmail.com. Our team is committed to provide a quick and supportive service throughout the publication process. A complete list of journals can be found at: http://sites.google.com/site/ijcsis/ IJCSIS Vol. 10, No. 3, March 2012 Edition ISSN 1947-5500 � IJCSIS, USA & UK.