-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPlaystationNetworkAPI_server.py
58 lines (39 loc) · 1.99 KB
/
PlaystationNetworkAPI_server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# -*- coding: utf-8 -*-
import sys
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from PlaystationNetworkAPI_client import *
from ZSI.twisted.wsgi import SOAPApplication, soapmethod, SOAPHandlerChainFactory, WSGIApplication
import logging
logger = logging.getLogger(__name__)
from service.services import *
class PlaystationNetworkAPIService(SOAPApplication):
_wsdl = "".join(open("PlaystationNetworkAPI.wsdl").readlines())
_noget = "".join(open("noget.html").readlines())
@soapmethod(GetProfileSoapIn.typecode, GetProfileSoapOut.typecode, operation='GetProfile', soapaction='GetProfile' )
def soap_GetProfile(self, request, response, **kw):
logger.info("Creating CrawlerService & GetProfile")
result = CrawlerService().GetProfile(request._psnId)
# Usado para propóstios de testes apenas ;P
#result = DummyService().GetProfile(request._psnId)
logger.info("Returning Response")
response.GetProfileResult = result
return request, response
@soapmethod(GetOnlineFriendsSoapIn.typecode, GetOnlineFriendsSoapOut.typecode, operation='GetOnlineFriends', soapaction='GetOnlineFriends' )
def soap_GetOnlineFriends(self, request, response, **kw):
# Usado para propóstios de testes apenas ;P
#friends = DummyService().GetOnlineFriends()
friends = CrawlerService().GetOnlineFriends()
response.OnlineFriends = friends
return request,response
def _handle_GET(self, env, start_response):
if env['QUERY_STRING'].lower() == 'wsdl':
start_response("200 OK", [('Content-Type','text/xml')])
return [ self._wsdl ]
start_response("404 ERROR", [('Content-Type','text/html')])
return [ self._noget ]
"""
Serviço Principal que deste WS
"""
application = WSGIApplication()
application['PlaystationNetworkAPI'] = PlaystationNetworkAPIService()