這個任務是關於代會話ID,這對我來說是全新的,GAE Python和XML - ElementSoap&ElementTree的,HTTP服務器通信(WSDL)
這裏我使用GAE,&我的目標網址:HTTP :?//203.215.51.43/GVSignOn/ExecutePortType WSDL,這個實現我是 指這些文檔elementsoap,soapWebservice-GAE & Element-Soap
&我已經寫了一些程序以及,
#!/usr/bin/python
from elementsoap.ElementSOAP import *
from elementtree.ElementTree import Element, SubElement, tostring, QName
NS_SOAP_ENV = "{http://schemas.xmlsoap.org/soap/envelope/}"
NS_XSI = "{http://www.w3.org/2001/XMLSchema-instance}"
NS_XSD = "{http://www.w3.org/2001/XMLSchema}"
class SoapService:
def __init__(self, url=None):
self.__client = HTTPClient(url or self.url)
def call(self, action, request):
# build SOAP envelope
envelope = Element(NS_SOAP_ENV + "Envelope")
body = SubElement(envelope, NS_SOAP_ENV + "Body")
body.append(request)
# call the server
response = self.__client.do_request(
tostring(envelope),
extra_headers=[("SOAPAction", action)]
)
return response.getroot().find(body.tag)[0]
def SoapRequest(method):
# create a SOAP request element
request = Element(method)
request.set(
NS_SOAP_ENV + "operation",
"http://schemas.xmlsoap.org/soap/encoding/"
)
return request
def SoapElement(parent, name, type=None, text=None):
# add a typed SOAP element to a request structure
elem = SubElement(parent, name)
if type:
if not isinstance(type, QName):
type = QName("http://www.w3.org/2001/XMLSchema", type)
elem.set(NS_XSI + "type", type)
elem.text = text
return elem
class GVService(SoapService):
url = 203.215.51.43:80/GVSignOn/ExecutePortType
def SignOnReq(self):
action = 'urn:stc:egate:jce:prjGV_prjGV_BC_Redeem_OTDs:jcdGV_SignOnWSDL:signOn'
request = SoapRequest('{' + self.url + '}SignOnReq')
SoapElement(request, "TerminalId", "string", 'T1081')
SoapElement(request, "StoreCode", "string", '1006')
SoapElement(request, "TimeStamp", "string", '2012-08-03 00:00:00')
response = self.call(action, request)
return response.findtext("Msg")
現在調用此,
響應= GVService()SignOnReq()
但這裏提出了一個錯誤:
文件「C:\ Python25 \ Lib文件\ site-packages \ elementsoap \ HTTPClient.py「,行155,d o_request raise HTTPError(errcode,errmsg,headers,h.getfile()) elementsoap.HTTPClient.HTTPError:(500,'Internal Server Error ',,)
我無法在我的程序中指出確切的問題。請幫助。
請注意:
總之,我的輸入參數是,TerminalId,商店代碼,時間戳 和期望的響應參數是代碼,味精,&的SessionID &
我相信,我的錯誤僅在書面程序中,所以請參考此http://203.215.51.43/GVSignOn/ExecutePortType?WSDL鏈接以及pin-point mista KES與輸入數據&預期的輸出數據..
&也正在使用這裏GAE SDK 1.6.1v,和的python2.5進口elementsoap &的ElementTree模塊以及
讓我知道,如果你需要任何其他信息或需要修改查詢的信息。