这个任务是关于生成会话ID的,这对我来说是全新的,
这里正在使用 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 中引发 HTTPError(errcode, errmsg, headers, h.getfile()) elementsoap.HTTPClient.HTTPError: (500, '内部服务器错误', , )
我无法在我的程序中指出确切的问题。请帮助解决这个问题。
请注意:
简而言之,我的输入参数是TerminalId、StoreCode、TimeStamp 和期望响应参数是Code、Msg 和 SessionId &
我相信,我的错误仅限于书面程序,所以请参考这个http://203.215.51.43/GVSignOn/ExecutePortType?WSDL链接以及输入数据和预期输出数据的精确错误。
& 也在这里使用 GAE sdk 1.6.1v, Python2.5 并导入了 elementsoap & elementtree 模块
如果您需要任何其他信息或需要修改查询的信息,请告诉我。