Example #1
0
def formatFault(exc, service):
	if isinstance(exc, base.ValidationError):
		val = ZSI.Fault(ZSI.Fault.Client, unicodeXML(exc))
	else:
		val = ZSI.Fault(ZSI.Fault.Server, unicodeXML(exc))
	return val.AsSOAP(
		nsdict={"tns": base.getMetaText(service, "identifier")})
Example #2
0
    def processContent(self, content):
        try:
            try:
                self._content.append(content)
                self._contentLength = self._contentLength + len(content)
                if self._contentLength < self.contentLength():
                    return
                if self._contentLength > self.contentLength():
                    error = netsvc.SERVER_REQUEST_DECODING_ERROR
                    description = netsvc.SERVER_REQUEST_DECODING_ERROR_MESSAGE
                    origin = "netsvc.soap"
                    details = "Invalid content length."
                    raise netsvc.ServiceFailure(error, description, origin,
                                                details)
                content = string.join(self._content, "")

                ps = ZSI.ParsedSoap(content)

                data = ZSI._child_elements(ps.body_root)
                if len(data) == 0:
                    params = []
                else:
                    try:
                        tc = ZSI.TC.Any()
                        params = []
                        for e in data:
                            params.append(tc.parse(e, ps))
                    except ZSI.EvaluateException:
                        raise

                self._method = ps.body_root.localName

            except netsvc.ServiceFailure:
                raise
            except ZSI.EvaluateException:
                raise
            except:
                error = netsvc.SERVER_REQUEST_DECODING_ERROR
                description = netsvc.SERVER_REQUEST_DECODING_ERROR_MESSAGE
                origin = "netsvc.soap"
                details = netsvc.exceptionDescription()
                raise netsvc.ServiceFailure(error, description, origin,
                                            details)

            service = self.serviceEndPoint(self._binding)
            id = apply(service.__getattr__(self._method), params)
            self.processResponse(self.processResult, id)
            self.processFailure(self.processResult, id)

        except ZSI.EvaluateException, e:
            fault = ZSI.FaultFromZSIException(e)
            self.sendResult(500, fault.AsSOAP())
    def parse(self):
        data = ZSI._child_elements(self.root)
        if len(data) == 0:
            params = ()
        else:
            resolver = queryUtility(IZSIRequestType, name=self.target)
            if resolver is None:
                targetWithNamespace = "%s/%s" % (self.root.namespaceURI,
                                                 self.target)
                resolver = queryUtility(IZSIRequestType,
                                        name=targetWithNamespace)
            if resolver and hasattr(resolver, 'typecode'):
                tc = resolver.typecode
                params = [resolver.typecode.parse(self.root, self.parsed)]

                resolver = queryUtility(IZSIResponseType, name=self.target)
                if resolver is None:
                    targetWithNamespace = "%s/%s" % (self.root.namespaceURI,
                                                 self.target)

                    resolver = queryUtility(IZSIResponseType,
                                            name=targetWithNamespace)
                params.append(resolver)
            else:
                tc = TC.Any()
                params = [tc.parse(e, self.parsed) for e in data]
            params = tuple(params)
        return params
Example #4
0
 def _raise_exception(self, code, msg):
     if ZSI_AVAILABLE:
         msg = _propagate_stack_trace(self._cfg_manager, msg)
         raise ZSI.Fault('ZSI:' + code, msg)
     else:
         msg = "Optional library 'ZSI' is not available, so SOAP clients will not be supported. However, AbstractZSI is being used, so problems will arise"
         log.log(self, log.level.Error, msg)
         print >> sys.stderr, msg
    def test_local_anyType(self):
        """serialize an int via anyType, then parse it back.
        """
        import time
        pyobj = self.client_module.ReadSoapOut()
        pyobj.RItemList = pyobj.new_RItemList()
        item = pyobj.RItemList.new_Items()
        pyobj.RItemList.Items = [
            item,
        ]
        item.typecode.ofwhat[1].processContents = 'lax'
        item.Value = 123
        s = str(ZSI.SoapWriter().serialize(pyobj))

        ps = ZSI.ParsedSoap(s)
        pyobj = ps.Parse(pyobj.typecode)
        for item in pyobj.RItemList.Items:
            item.Value
Example #6
0
    def processResult(self, params):
        try:
            if self.failureOccurred():
                exception = self.currentFailure()
                error = exception.error()
                description = exception.description()
                origin = exception.origin()
                details = exception.details()
                raise netsvc.ServiceFailure(error, description, origin,
                                            details)

            params = [params]
            reply = StringIO.StringIO()
            ZSI.SoapWriter(reply).serialize(
                params, ZSI.TC.Any(aslist=1, pname=self._method + 'Response'))

            self.sendResult(200, reply.getvalue())
        except netsvc.ServiceFailure, exception:
            try:
                detail = FAULT_DETAIL % (SCHEMA_URI, exception.error,
                                         _escape(exception.description),
                                         _escape(exception.origin),
                                         _escape(exception.details))

                if exception.origin == "netsvc" and \
                    (exception.error == netsvc.SERVER_METHOD_UNAVAILABLE or \
                    exception.error == netsvc.SERVER_PARAMETERS_INCORRECT or \
                    exception.error == netsvc.SERVER_REQUEST_DECODING_ERROR):
                    fault = ZSI.Fault(ZSI.Fault.Client, "Request Failed", None,
                                      detail, None)
                else:
                    fault = ZSI.Fault(ZSI.Fault.Server, "Request Failed", None,
                                      detail, None)

                body = fault.AsSOAP()
                self.sendResult(500, body)
            except:
                self.sendError(500, _escape(netsvc.exceptionDetails()))
Example #7
0
    def check_union_long(self):
        import time
        typecode = GED("http://www.pasoa.org/schemas/version024/PStruct.xsd", "localPAssertionId")
        for value in (1234455, "whatever", "urn:whatever"):
            sw = ZSI.SoapWriter()
            sw.serialize(value, typecode)

            xml = str(sw)
            ps = ParsedSoap(xml)
            pyobj = ps.Parse(typecode)

            # Union Limitation:  
            #     currently it tries to parse it sequentially via memberTypes,
            #     so string is going to parse the URI when we want anyURI
            self.failUnless(value == pyobj, 'Expected equivalent')
Example #8
0
def serializePrimaryTable(data, service):
	"""returns a SOAP serialization of the DataSet data's primary table.
	"""
	table = data.getPrimaryTable()
	tns = base.getMetaText(service, "identifier")
	class Row(TC.Struct):
		def __init__(self):
			TC.Struct.__init__(self, None, [
				sqltypeToTC(f.type)(pname=(tns, f.name))
					for f in table.tableDef],
				pname=(tns, "outRow"))

	class Table(list):
		typecode = TC.Array((tns, 'outRow'), Row(), 
			pname=(tns, 'outList'))

	mapped = Table(
		base.SerManager(table, mfRegistry=_wsdlMFRegistry).getMappedValues())
	sw = ZSI.SoapWriter(nsdict={"tns": tns})
	sw.serialize(mapped).close()
	return str(sw)
Example #9
0
    def ReceiveSOAP(self, response, readerclass=None, **kw):
        '''Get back a SOAP message.
        '''

        self.ReceiveRaw(response)

        if self.ps: return self.ps
        if not self.IsSOAP(response):
            raise TypeError(
                'Response is "%s", not in %r' % (response.headers.get_content_type(), SOAP_TYPES))
        if len(response.content) == 0:
            raise TypeError('Received empty response')

        self.ps = ZSI.ParsedSoap(response.content,
                             readerclass=readerclass or self.readerclass,
                             encodingStyle=kw.get('encodingStyle'))

        if self.sig_handler is not None:
            self.sig_handler.verify(self.ps)

        return self.ps
Example #10
0
def __main():
    import ZSI, ZSI.schema as schema
    data = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header><AffinityCacheHeader xmlns="http://www.msn.com/webservices/storage/2008"><CacheKey>1p8CXNxj8mTbyfRy5cdbxUbNpOw5IAof_RjSy7XAotTIAs1eKcah9MQg</CacheKey></AffinityCacheHeader><StorageUserHeader xmlns="http://www.msn.com/webservices/storage/2008"><Puid>0</Puid><Cid>0</Cid><ApplicationId>0</ApplicationId><TicketToken>t=EwDoAW+jAAAUVwo8hY/Rg6HvEdmXr19KcNgO+7mAAA3oPdbFO1wSu82lRckR/LUL2fSAHbA7skahr3eq37BfYX1s7Dcj6PKkLco7bUKCEP9NPZGXeM5zLb6SgsnDwnrrgs6rjZrOAyz2Nf1Jg8tj0uDg4BzCtEm2lQi7P1LjGrHfvkD4bJKQTRW2Ot8W4zop6cCSPKjmKxH15v/cXqlkA2YAAAh2WM/FIDyMijgBvRY/ln+7e+GXZ+0dIb1AlHP47KUaEcX4HI1UgJMnKQ7Z2ybcWP19kthAYQLmc1QhCMfocKWTbniLzWO+H4EEwIf7VQGyGzgCsQ+L9Oz+oxad4A7WYOcmO58yIYEYETk7rYhRzPXYKbLM2fM/WVg6rrPC3LG/oyqMkbmQf6I0ebQxOPv/k7npSwpMnj4bMmMh/TjoA+4lSQrjx4iCT6ZJq9jmLRyRH5mlJ/ultaXCAFVttQ7dAEGYu7YuZOActLa5DyUYQ1/F/AK21k3VX+5YvTVvIXFE1ourC+YumAJlouczBvtGIy5DNvAwpCIXeqHDP6iYGQpID8cTiCf95Ctq3oK5pHmHSfCPi+wymbpBVzlVNlRF6kVuR64oxMFX+CojJLyQmv6UYSlU0YVZ1e9zi9pcBa42huJ5dQE=&amp;p=</TicketToken><IsAdmin>false</IsAdmin></StorageUserHeader></soap:Header><soap:Body><GetProfileResponse xmlns="http://www.msn.com/webservices/storage/2008"><GetProfileResult><ResourceID>C9133A4085E57C34!101</ResourceID><DateModified>2011-03-01T06:24:21.577-08:00</DateModified><ExpressionProfile><ResourceID>C9133A4085E57C34!130</ResourceID><DateModified>2011-02-28T15:00:25.977-08:00</DateModified><Photo><ItemType>Photo</ItemType><ResourceID>C9133A4085E57C34!132</ResourceID><DateModified>2011-02-28T15:00:26.713-08:00</DateModified><Name>Webcam</Name><DocumentStreams><DocumentStream xsi:type="PhotoStream"><DocumentStreamName>UserTileStatic</DocumentStreamName><MimeType>image/jpeg</MimeType><DataSize>2347</DataSize><PreAuthURL>http://sn2files.storage.msn.com/y1pSLNg0PlgMWDC0wQ8Qeriz4OKCmrd1fT-P6-GIgReDdlxsCQxX6c0-j_35MhEGCk0K1n8et_j8xjXVjSDxQ7dQg</PreAuthURL><PreAuthURLPartner>http://internal.sn2.pvt-livefilestore.com/y1pSLNg0PlgMWDC0wQ8Qeriz4OKCmrd1fT-P6-GIgReDdlxsCQxX6c0-j_35MhEGCk0K1n8et_j8xjXVjSDxQ7dQg</PreAuthURLPartner><WriteMode>Overwrite</WriteMode><SHA1Hash>rG952Xtm0+Ctn0o/LLeOorBBtik=</SHA1Hash><Genie>false</Genie><StreamVersion>258</StreamVersion><DocumentStreamType>UserTileStatic</DocumentStreamType><SizeX>96</SizeX><SizeY>96</SizeY></DocumentStream></DocumentStreams></Photo><PersonalStatus>- on www.ebuddy.com Web Messenger</PersonalStatus><PersonalStatusLastModified>2010-05-27T13:05:25-07:00</PersonalStatusLastModified><DisplayName>Michael</DisplayName><DisplayNameLastModified>2008-01-10T16:02:26-08:00</DisplayNameLastModified><StaticUserTilePublicURL>http://sn2files.storage.msn.com/y1pvl2Jn-4-_9Ofj9SL1vLwNeWQ5OcYt-g4qxVurMMylKIhNnQs6kWAFBc3RiEws2KTD8AV8EfPw6E</StaticUserTilePublicURL></ExpressionProfile></GetProfileResult></GetProfileResponse></soap:Body></soap:Envelope>'

    ps = ZSI.ParsedSoap(data)
    pname = ps.body_root.namespaceURI, ps.body_root.localName
    el_type = schema.GTD(*pname)
    if el_type is not None:
        tc = el_type(pname)
    else:
        tc = schema.GED(*pname)

    reply = ps.Parse(tc)

    profile = Profile.from_zsi(reply.GetProfileResult)
    try:
        print profile.serialize()
    except:
        import traceback
        traceback.print_exc()

    return profile
Example #11
0
  def execute(self):
    try:
      if os.environ["REQUEST_METHOD"] != "POST":
	self._error(400,"Only POST method supported.")
	return

      ct = string.split(os.environ.get("CONTENT_TYPE","text/xml"),';')[0]
      if ct != "text/xml":
	self._error(400,"Invalid content type.")
	return

      length = int(os.environ["CONTENT_LENGTH"])
      content = sys.stdin.read(length)

      ps = ZSI.ParsedSoap(content)
 
      data = ZSI._child_elements(ps.body_root)
      if len(data) == 0:
	params = []
      else:
	try:
	  tc = ZSI.TC.Any()
	  params = []
	  for e in data:
	    params.append(tc.parse(e,ps))
	except ZSI.EvaluateException:
	  raise
 
      method = ps.body_root.localName

      result = self.dispatch(method,params)

      result = [result]
      reply = StringIO.StringIO()
      ZSI.SoapWriter(reply).serialize(result,
          ZSI.TC.Any(aslist=1,pname=method + 'Response'))

      body = reply.getvalue()

      print "Status: 200"
      print "Content-Type: text/xml"
      print "Content-Length: %d" % len(body)
      print
      sys.stdout.write(body)

    except SystemExit:
      pass

    except ServiceFailure, exception:
      result = {}
      result["error"] = exception.error
      result["description"] = exception.description
      result["origin"] = exception.origin
      result["details"] = exception.details

      detail = FAULT_DETAIL % (SCHEMA_URI,
	  exception.error,_escape(exception.description),
	  _escape(exception.origin),_escape(exception.details))

      if exception.origin == "netsvc" and \
	  (exception.error == netrpc.SERVER_METHOD_UNAVAILABLE or \
	  exception.error == netrpc.SERVER_PARAMETERS_INCORRECT or \
	  exception.error == netrpc.SERVER_REQUEST_DECODING_ERROR):
	fault = ZSI.Fault(ZSI.Fault.Client,
	    "Request Failed",None,detail,None)
      else:
	fault = ZSI.Fault(ZSI.Fault.Server,
	    "Request Failed",None,detail,None)

      body = fault.AsSOAP()

      print "Status: 500"
      print "Content-Type: text/xml"
      print "Content-Length: %d" % len(body)
      print
      sys.stdout.write(body)
Example #12
0
  def call(self,method,params,kw):
    try:
      if RemoteService._debug:
	RemoteService._request = ""
	RemoteService._response = ""
      if self._type != "http":
	error = CLIENT_SERVICE_ADDRESS_INVALID
	description = CLIENT_SERVICE_ADDRESS_INVALID_MESSAGE
	origin = "netrpc.soap"
	details = self._url
	raise AddressInvalid(error,description,origin,details)

      try:
	ns = kw.get("ns",self._ns)
	soapaction = kw.get("soapaction",self._soapaction)
	if soapaction == None:
	  soapaction = '""'
	d = {}
	if ns:
	  d[''] = ns
	s = StringIO.StringIO()
        sw = ZSI.SoapWriter(s,nsdict=d)
        #sw.serialize(params,ZSI.TC.Any(method))
        sw.serialize(params,ZSI.TC.Any(method,aslist=1))
        sw.close()
        body = s.getvalue()
      except ServiceFailure:
        raise
      except:
	error = CLIENT_REQUEST_ENCODING_ERROR
	description = CLIENT_REQUEST_ENCODING_ERROR_MESSAGE
	origin = "netrpc.soap"
	details = exceptionDescription()
	raise ServiceFailure(error,description,origin,details)

      try:
	request = httplib.HTTP(self._host)
	request.putrequest("POST",self._path)
	request.putheader("Host",self._host)
	request.putheader("Connection","Close")
	request.putheader("Content-Type","text/xml; charset=utf-8")
	request.putheader("Content-Length",str(len(body)))
	request.putheader("User-Agent","OSE/SOAP(ZSI)")
	request.putheader("SOAPAction",soapaction)
	if self._login != None and self._password != None:
	  info = "%s:%s" % (self._login,self._password)
	  info = base64.encodestring(info)
	  info = "Basic %s" % string.strip(info)
	  request.putheader("Authorization",info)
	request.endheaders()
	if RemoteService._debug:
	  headers = "POST %s HTTP/1.0" % self._path
	  headers = "%s\nHost: %s" % (headers,self._host)
	  headers = "%s\nConnection: Close" % headers
	  headers = "%s\nContent-Type: text/xml; charset=utf-8" % headers
	  headers = "%s\nContent-Length: %s" % (headers,str(len(body)))
	  headers = "%s\nUser-Agent: OSE/SOAP(ZSI)" % headers
	  headers = "%s\nSOAPAction: %s" % (headers,soapaction)
	  RemoteService._request = headers + "\n\n" + body
	request.send(body)
      except socket.error,exception:
	error = CLIENT_SERVICE_UNAVAILABLE
	description = CLIENT_SERVICE_UNAVAILABLE_MESSAGE
	origin = "netrpc.soap"
	details = exceptionDescription()
	raise ServiceUnavailable(error,description,origin,details)

      error,description,headers = request.getreply()
      if RemoteService._debug:
	RemoteService._response = "HTTP/1.0 %d %s\r\n" % (error,description)
        for line in headers.headers:
	  RemoteService._response = RemoteService._response + line;
	RemoteService._response = string.replace(
	    RemoteService._response,"\r\n","\n")
      if error != 200:
	if error == 500:
	  if headers.has_key("content-type") and \
	      string.split(headers["content-type"],';')[0] == "text/xml":
	    error = 200

	if error != 200:
	  origin = "netrpc.soap"
	  response = request.getfile()

	  # This alone was loosing data
	  # under Mac OS for some reason.
	  #details = response.read()

	  details = ""
	  content = []
	  while 1:
	    try:
	      # Large read was still loosing
	      # data under Mac OS. Small read
	      # works okay though. Strange!!!
	      data = response.read(64)
	      if data:
		content.append(data)
	      else:
		break
	    except:
	      break
	  details = string.join(content,'')

	  if RemoteService._debug:
	    RemoteService._response = RemoteService._response + "\n" + details
	  response.close()
	  if error == 401:
	    raise AuthenticationFailure(error,description,origin,details)
	  elif error == 404:
	    raise ServiceUnavailable(error,description,origin,details)
	  else:
	    raise TransportFailure(error,description,origin,details)

      error = CLIENT_RESPONSE_HEADERS_INVALID
      description = CLIENT_RESPONSE_HEADERS_INVALID_MESSAGE
      origin = "netrpc.soap"
      if not headers.has_key("content-type"):
	details = "The Content-Type header does not exist."
	raise ServiceFailure(error,description,origin,details)
      if string.split(headers["content-type"],';')[0] != "text/xml":
	details = "Unexpected value of %s for Content-Type."
	details = details % `headers["content-type"]`
	raise ServiceFailure(error,description,origin,details)
      if not headers.has_key("content-length"):
	details = "The Content-Length header does not exist."
	raise ServiceFailure(error,description,origin,details)
      try:
	expect = int(headers["content-length"])
      except:
	details = "Content length not an integer, but %s."
	details = details % `headers["content-length"]`
	raise ServiceFailure(error,description,origin,details)

      try:
	response = request.getfile()
	actual = 0
	data = []
	if RemoteService._debug:
	  RemoteService._response = RemoteService._response + "\n"
	while 1:
	  content = response.read(4096)
	  if not content:
	    break
	  data.append(content)
          actual = actual + len(content)
	  if RemoteService._debug:
	    RemoteService._response = RemoteService._response + content
	if expect != actual:
	  error = CLIENT_RESPONSE_HEADERS_INVALID
	  description = CLIENT_RESPONSE_HEADERS_INVALID_MESSAGE
	  origin = "netrpc.soap"
	  details = "Length of content was %d, expected %d."
	  details = details % (actual,expect)
	  raise ServiceFailure(error,description,origin,details)
	data = string.join(data,"")
	result = ZSI.ParsedSoap(data)
      except ServiceFailure:
        raise
      except:
	error = CLIENT_RESPONSE_DECODING_ERROR
	description = CLIENT_RESPONSE_DECODING_ERROR_MESSAGE
	origin = "netrpc.soap"
	details = exceptionDescription()
	raise ServiceFailure(error,description,origin,details)

      if result.IsAFault():
	try:
	  fault = ZSI.FaultFromFaultMessage(result)
          error = SERVER_UNKNOWN_ERROR
          description = fault.string
          origin = "netrpc.soap"
          details = ""
          if type(fault.detail) in ZSI._seqtypes:
	    if len(fault.detail) != 0:
	      elt = fault.detail[0]
              if elt.nodeName == "OSE:ServiceFailure":
		tc = ZSI.TC.Struct(None,[ZSI.TC.Integer('error'),
                    ZSI.TC.String('description'),ZSI.TC.String('origin'),
		    ZSI.TC.String('details')],'ServiceFailure')
                detail = tc.parse(elt,result)
		error = detail['error']
		description = detail['description']
		origin = detail['origin']
		details = detail['details']
              elif elt.nodeName == "ZSI:FaultDetail":
		tc = ZSI.TC.Struct(None,[ZSI.TC.String('string'),
                    ZSI.TC.String('trace')],'FaultDetail')
                detail = tc.parse(elt,result)
                details = detail['string'] + '\n\n' + detail['trace']
              elif elt.nodeName == "ZSI:ParseFaultDetail":
		tc = ZSI.TC.Struct(None,[ZSI.TC.String('string'),
                    ZSI.TC.String('trace')],'FaultDetail')
                detail = tc.parse(elt,result)
                details = detail['string'] + '\n\n' + detail['trace']
              else:
		details = fault.detail
          elif type(fault.detail) in ZSI._stringtypes:
	    details = fault.detail
        except:
	  error = CLIENT_RESPONSE_DECODING_ERROR
          description = CLIENT_RESPONSE_DECODING_ERROR_MESSAGE
          origin = "netrpc.soap"
          details = exceptionDescription()
          raise ServiceFailure(error,description,origin,details)
        raise ServiceFailure(error,description,origin,details)

      tc = ZSI.TC.Any()
      data = ZSI._child_elements(result.body_root)
      if len(data) == 0:
	return None
      return tc.parse(data[0],result)
Example #13
0
class RpcServlet(netsvc.HttpServlet, netsvc.Service):
    def __init__(self, session, binding):
        netsvc.HttpServlet.__init__(self, session)
        netsvc.Service.__init__(self, "", "", netsvc.SERVICE_HIDDEN)
        self._binding = binding
        self._method = None
        self._content = []
        self._contentLength = 0

    def destroyServlet(self):
        netsvc.HttpServlet.destroyServlet(self)
        netsvc.Service.destroyReferences(self)

    def processRequest(self):
        try:
            if self.requestMethod() != "POST":
                self.sendError(400, "Only POST method supported.")
                return
            if self.contentLength() <= 0:
                self.sendError(400, "Invalid content length.")
                return
        except:
            self.sendError(500, _escape(netsvc.exceptionDetails()))

    def processContent(self, content):
        try:
            try:
                self._content.append(content)
                self._contentLength = self._contentLength + len(content)
                if self._contentLength < self.contentLength():
                    return
                if self._contentLength > self.contentLength():
                    error = netsvc.SERVER_REQUEST_DECODING_ERROR
                    description = netsvc.SERVER_REQUEST_DECODING_ERROR_MESSAGE
                    origin = "netsvc.soap"
                    details = "Invalid content length."
                    raise netsvc.ServiceFailure(error, description, origin,
                                                details)
                content = string.join(self._content, "")

                ps = ZSI.ParsedSoap(content)

                data = ZSI._child_elements(ps.body_root)
                if len(data) == 0:
                    params = []
                else:
                    try:
                        tc = ZSI.TC.Any()
                        params = []
                        for e in data:
                            params.append(tc.parse(e, ps))
                    except ZSI.EvaluateException:
                        raise

                self._method = ps.body_root.localName

            except netsvc.ServiceFailure:
                raise
            except ZSI.EvaluateException:
                raise
            except:
                error = netsvc.SERVER_REQUEST_DECODING_ERROR
                description = netsvc.SERVER_REQUEST_DECODING_ERROR_MESSAGE
                origin = "netsvc.soap"
                details = netsvc.exceptionDescription()
                raise netsvc.ServiceFailure(error, description, origin,
                                            details)

            service = self.serviceEndPoint(self._binding)
            id = apply(service.__getattr__(self._method), params)
            self.processResponse(self.processResult, id)
            self.processFailure(self.processResult, id)

        except ZSI.EvaluateException, e:
            fault = ZSI.FaultFromZSIException(e)
            self.sendResult(500, fault.AsSOAP())
        except netsvc.ServiceFailure, exception:
            try:
                detail = FAULT_DETAIL % (SCHEMA_URI, exception.error,
                                         _escape(exception.description),
                                         _escape(exception.origin),
                                         _escape(exception.details))
                fault = ZSI.Fault(ZSI.Fault.Client, "Request Failed", None,
                                  detail, None)
                body = fault.AsSOAP()
                self.sendResult(500, body)
            except:
                self.sendError(500, _escape(netsvc.exceptionDetails()))
Example #14
0
 def __repr__(self):
     return "<%s instance %s>" % (self.__class__.__name__, ZSI._get_idstr(self))
            self._setError(ZSI.FaultFromException(e, 1))
            return

        # Parse the SOAP input.
        try:
            docstyle = 0 # cant really tell...
            resolver = None # XXX
            root = self._root = parsed.body_root
            target = self._target = root.localName

            self.setPathSuffix(target.split('.'))

            if docstyle:
                self._args = (root)
            else:
                data = ZSI._child_elements(root)
                if len(data) == 0:
                    self._args = ()
                else:
                    try:
                        try:
                            type = data[0].localName
                            tc = getattr(resolver, type).typecode
                        except Exception, e:
                            tc = TC.Any()
                        self._args = [tc.parse(e, parsed) for e in data]
                        self._args = tuple(self._args)
                    except ZSI.EvaluateException, e:
                        self._error = ZSI.FaultFromZSIException(e)
                    return