Ejemplo n.º 1
0
    def do_POST(self):
        '''The POST command.  This is called by HTTPServer, not twisted.
        action -- SOAPAction(HTTP header) or wsa:Action(SOAP:Header)
        '''
        global _contexts

        soapAction = self.headers.getheader('SOAPAction')
        post = self.path
        if not post:
            raise PostNotSpecified('HTTP POST not specified in request')
        if soapAction:
            soapAction = soapAction.strip('\'"')
        post = post.strip('\'"')
        try:
            ct = self.headers['content-type']
            if ct.startswith('multipart/'):
                cid = resolvers.MIMEResolver(ct, self.rfile)
                xml = cid.GetSOAPPart()
                #ps = ParsedSoap(xml, resolver=cid.Resolve, readerclass=DomletteReader)
                ps = ParsedSoap(xml, resolver=cid.Resolve)
            else:
                length = int(self.headers['content-length'])
                #ps = ParsedSoap(self.rfile.read(length), readerclass=DomletteReader)
                ps = ParsedSoap(self.rfile.read(length))
        except ParseException, e:
            self.send_fault(FaultFromZSIException(e))
Ejemplo n.º 2
0
def AsCGI(nsdict={}, typesmodule=None, rpc=False, modules=None):
    '''Dispatch within a CGI script.
    '''
    if os.environ.get('REQUEST_METHOD') != 'POST':
        _CGISendFault(Fault(Fault.Client, 'Must use POST'))
        return
    ct = os.environ['CONTENT_TYPE']
    try:
        if ct.startswith('multipart/'):
            cid = resolvers.MIMEResolver(ct, sys.stdin)
            xml = cid.GetSOAPPart()
            ps = ParsedSoap(xml, resolver=cid.Resolve)
        else:
            length = int(os.environ['CONTENT_LENGTH'])
            ps = ParsedSoap(sys.stdin.read(length))
    except ParseException as e:
        _CGISendFault(FaultFromZSIException(e))
        return
    _Dispatch(ps,
              modules,
              _CGISendXML,
              _CGISendFault,
              nsdict=nsdict,
              typesmodule=typesmodule,
              rpc=rpc)
Ejemplo n.º 3
0
    def do_POST(self):
        '''The POST command.
        '''
        try:
            ct = self.headers['content-type']
            if ct.startswith('multipart/'):
                cid = resolvers.MIMEResolver(ct, self.rfile)
                xml = cid.GetSOAPPart()
                ps = ParsedSoap(xml, resolver=cid.Resolve)
            else:
                length = int(self.headers['content-length'])
                ps = ParsedSoap(self.rfile.read(length))
        except ParseException as e:
            self.send_fault(FaultFromZSIException(e))
            return
        except Exception as e:
            # Faulted while processing; assume it's in the header.
            self.send_fault(FaultFromException(e, 1, sys.exc_info()[2]))
            return

        _Dispatch(ps,
                  self.server.modules,
                  self.send_xml,
                  self.send_fault,
                  docstyle=self.server.docstyle,
                  nsdict=self.server.nsdict,
                  typesmodule=self.server.typesmodule,
                  rpc=self.server.rpc)
Ejemplo n.º 4
0
    def do_POST(self):
        '''The POST command.  This is called by HTTPServer, not twisted.
        action -- SOAPAction(HTTP header) or wsa:Action(SOAP:Header)
        '''
        global _contexts

        soapAction = self.headers.getheader('SOAPAction')
        post = self.path
        if not post:
            raise PostNotSpecified('HTTP POST not specified in request')
        if soapAction:
            soapAction = soapAction.strip('\'"')
        post = post.strip('\'"')
        try:
            ct = self.headers['content-type']
            if ct.startswith('multipart/'):
                cid = resolvers.MIMEResolver(ct, self.rfile)
                xml = cid.GetSOAPPart()
                ps = ParsedSoap(xml,
                                resolver=cid.Resolve,
                                readerclass=DomletteReader)
            else:
                length = int(self.headers['content-length'])
                ps = ParsedSoap(self.rfile.read(length),
                                readerclass=DomletteReader)
        except ParseException as e:
            self.send_fault(FaultFromZSIException(e))
        except Exception as e:
            # Faulted while processing; assume it's in the header.
            self.send_fault(FaultFromException(e, 1, sys.exc_info()[2]))
        else:
            # Keep track of calls
            thread_id = _thread.get_ident()
            _contexts[thread_id] = SOAPContext(self.server, xml, ps,
                                               self.connection, self.headers,
                                               soapAction)

            try:
                _Dispatch(ps,
                          self.server,
                          self.send_xml,
                          self.send_fault,
                          post=post,
                          action=soapAction)
            except Exception as e:
                self.send_fault(FaultFromException(e, 0, sys.exc_info()[2]))

            # Clean up after the call
            if thread_id in _contexts:
                del _contexts[thread_id]
Ejemplo n.º 5
0
 def do_POST(self):
     '''The POST command.
     '''
     try:
         ct = self.headers['content-type']
         if ct.startswith('multipart/'):
             cid = resolvers.MIMEResolver(ct, self.rfile)
             xml = cid.GetSOAPPart()
             ps = ParsedSoap(xml, resolver=cid.Resolve)
         else:
             length = int(self.headers['content-length'])
             ps = ParsedSoap(self.rfile.read(length))
     except ParseException, e:
         self.send_fault(FaultFromZSIException(e))
         return
Ejemplo n.º 6
0
def AsJonPy(request=None, modules=None, **kw):
    '''Dispatch within a jonpy CGI/FastCGI script.
    '''

    kw['request'] = request
    if request.environ.get('REQUEST_METHOD') != 'POST':
        _JonPySendFault(Fault(Fault.Client, 'Must use POST'), **kw)
        return
    ct = request.environ['CONTENT_TYPE']
    try:
        if ct.startswith('multipart/'):
            cid = resolvers.MIMEResolver(ct, request.stdin)
            xml = cid.GetSOAPPart()
            ps = ParsedSoap(xml, resolver=cid.Resolve)
        else:
            length = int(request.environ['CONTENT_LENGTH'])
            ps = ParsedSoap(request.stdin.read(length))
    except ParseException, e:
        _JonPySendFault(FaultFromZSIException(e), **kw)
        return