1

我有一个使用 ZSI 编写的客户端代码,我想设置一个带有静态响应的模拟。我尝试使用 urllib2 包,但它不起作用,因为返回类型是 urllib2 中的字符串,这里的响应是另一种我不知道的类型。帮帮我……有人可以帮我吗?

代码:

from PayDayLoans_services_types import *
import urlparse, types
from ZSI.TCcompound import ComplexType, Struct
from ZSI import client
import ZSI

# Locator
class PayDayLoansLocator:
    PayDayLoansSoap_address = "https://something.com/something.asmx"
    def getPayDayLoansSoapAddress(self):
        return PayDayLoansLocator.PayDayLoansSoap_address
    def getPayDayLoansSoap(self, url=None, **kw):
        return PayDayLoansSoapSOAP(url or PayDayLoansLocator.PayDayLoansSoap_address, **kw)

# Methods
class PayDayLoansSoapSOAP:
    def __init__(self, url, **kw):
        kw.setdefault("readerclass", None)
        kw.setdefault("writerclass", None)
        # no resource properties
        self.binding = client.Binding(url=url, **kw)
        # no ws-addressing

    # op: LoanResubmitXML
    def LoanResubmitXML(self, request):
        if isinstance(request, LoanResubmitXMLSoapIn) is False:
            raise TypeError, "%s incorrect request type" % (request.__class__)
        kw = {}
        # no input wsaction
        self.binding.Send(None, None, request, soapaction="http://www.something.com/Request/ResubmitXML", **kw)
        # no output wsaction
        response = self.binding.Receive(LoanResubmitXMLSoapOut.typecode)
        return response
4

0 回答 0