这个任务是关于代会话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模块以及
让我知道,如果你需要任何其他信息或需要修改查询的信息。