コード例 #1
0
ファイル: wsgi.py プロジェクト: propars/soaplib
    def __handle_soap_request(self, req_env, start_response):
        ctx = soaplib.core.MethodContext()

        # implementation hook
        self.on_wsgi_call(req_env)

        in_string, in_string_charset = _reconstruct_soap_request(req_env)

        ## &ek
        in_string = in_string.replace("ns3:documentRequest","ns0:sendDocument")
        in_string = in_string.replace('xmlns:ns3="http://gib.gov.tr/vedop3/eFatura"','xmlns:ns3="http://gib.gov.tr/vedop3/eFatura" xmlns:ns0="soap.views"'  )
        in_string = in_string.replace("fileName","ns0:fileName")
        in_string = in_string.replace("binaryData","ns0:binaryData")
        in_string = in_string.replace("hash","ns0:hash")
        in_string = in_string.replace("ns0:ns0","ns0") 
        # &ek-

        in_object = self.get_in_object(ctx, in_string, in_string_charset)

        return_code = HTTP_200
        if ctx.in_error:
            out_object = ctx.in_error
            return_code = HTTP_500
        else:
            assert ctx.service != None
            out_object = self.get_out_object(ctx, in_object)
            if ctx.out_error:
                out_object = ctx.out_error
                return_code = HTTP_500

        out_string = self.get_out_string(ctx, out_object)

        http_resp_headers = {
            'Content-Type': 'text/xml',
            'Content-Length': '0',
        }

        # implementation hook
        self.on_wsgi_return(req_env, http_resp_headers, out_string)

        if ctx.descriptor and ctx.descriptor.mtom:
            # when there are more than one return type, the result is 
            # encapsulated inside a list. when there's just one, the result
            # is returned unencapsulated. the apply_mtom always expects the
            # objects to be inside an iterable, hence the following test.
            out_type_info = ctx.descriptor.out_message._type_info
            if len(out_type_info) == 1:
                out_object = [out_object]

            http_resp_headers, out_string = apply_mtom(http_resp_headers,
                    out_string, ctx.descriptor.out_message._type_info.values(),
                    out_object)

        # initiate the response
        http_resp_headers['Content-Length'] = str(len(out_string))
        start_response(return_code, http_resp_headers.items())

        return [out_string]
コード例 #2
0
ファイル: metaconfigure.py プロジェクト: jonathanfine/soaplib
    def parse_soap_request(self):
        soap = self.request.other.get('SOAPXML') or self.request['BODY']
        #these are lxml etree elements
        payload, header = self.from_soap()
        ctx = soaplib.core.MethodContext()

        content_type = cgi.parse_header(self.request.get("CONTENT_TYPE"))
        charset = content_type[1].get('charset', None)

        if charset is None:
            charset = 'ascii'

        in_string = collapse_swa(content_type, soap)
        in_object = self.get_in_object(ctx, in_string, charset)
        return_code = HTTP_200

        if ctx.in_error:
            out_object = ctx.in_error
            return_code = HTTP_500
        else:
            assert ctx.service != None
            out_object = self.get_out_object(ctx, in_object)
            if ctx.out_error:
                out_object = ctx.out_error
                return_code = HTTP_500

        out_string = self.get_out_string(ctx, out_object)

        http_resp_headers = {
            'Content-Type': 'text/xml',
            'Content-Length': '0',
            }

        if ctx.descriptor and ctx.descriptor.mtom:
            # when there are more than one return type, the result is
            # encapsulated inside a list. when there's just one, the result
            # is returned unencapsulated. the apply_mtom always expects the
            # objects to be inside an iterable, hence the following test.
            out_type_info = ctx.descriptor.out_message._type_info
            if len(out_type_info) == 1:
                out_object = [out_object]

            http_resp_headers, out_string = apply_mtom(http_resp_headers,
                                                       out_string, ctx.descriptor.out_message._type_info.values(),
                                                       out_object)

        # initiate the response
        http_resp_headers['Content-Length'] = str(len(out_string))

        rc = RespComp(out_string, http_resp_headers, return_code)

        return rc
コード例 #3
0
    def parse_soap_request(self):
        soap = self.request.other.get('SOAPXML') or self.request['BODY']
        #these are lxml etree elements
        payload, header = self.from_soap()
        ctx = soaplib.core.MethodContext()

        content_type = cgi.parse_header(self.request.get("CONTENT_TYPE"))
        charset = content_type[1].get('charset', None)

        if charset is None:
            charset = 'ascii'

        in_string = collapse_swa(content_type, soap)
        in_object = self.get_in_object(ctx, in_string, charset)
        return_code = HTTP_200

        if ctx.in_error:
            out_object = ctx.in_error
            return_code = HTTP_500
        else:
            assert ctx.service != None
            out_object = self.get_out_object(ctx, in_object)
            if ctx.out_error:
                out_object = ctx.out_error
                return_code = HTTP_500

        out_string = self.get_out_string(ctx, out_object)

        http_resp_headers = {
            'Content-Type': 'text/xml',
            'Content-Length': '0',
        }

        if ctx.descriptor and ctx.descriptor.mtom:
            # when there are more than one return type, the result is
            # encapsulated inside a list. when there's just one, the result
            # is returned unencapsulated. the apply_mtom always expects the
            # objects to be inside an iterable, hence the following test.
            out_type_info = ctx.descriptor.out_message._type_info
            if len(out_type_info) == 1:
                out_object = [out_object]

            http_resp_headers, out_string = apply_mtom(
                http_resp_headers, out_string,
                ctx.descriptor.out_message._type_info.values(), out_object)

        # initiate the response
        http_resp_headers['Content-Length'] = str(len(out_string))

        rc = RespComp(out_string, http_resp_headers, return_code)

        return rc
コード例 #4
0
ファイル: wsgi.py プロジェクト: PArun/soaplib
    def __handle_soap_request(self, req_env, start_response):
        ctx = soaplib.core.MethodContext()

        # implementation hook
        self.on_wsgi_call(req_env)

        in_string, in_string_charset = _reconstruct_soap_request(req_env)

        in_object = self.get_in_object(ctx, in_string, in_string_charset)

        return_code = HTTP_200
        if ctx.in_error:
            out_object = ctx.in_error
            return_code = HTTP_500
        else:
            assert ctx.service != None
            out_object = self.get_out_object(ctx, in_object)
            if ctx.out_error:
                out_object = ctx.out_error
                return_code = HTTP_500

        out_string = self.get_out_string(ctx, out_object)

        http_resp_headers = {
            'Content-Type': 'text/xml',
            'Content-Length': '0',
        }

        # implementation hook
        self.on_wsgi_return(req_env, http_resp_headers, out_string)

        if ctx.descriptor and ctx.descriptor.mtom:
            # when there are more than one return type, the result is 
            # encapsulated inside a list. when there's just one, the result
            # is returned unencapsulated. the apply_mtom always expects the
            # objects to be inside an iterable, hence the following test.
            out_type_info = ctx.descriptor.out_message._type_info
            if len(out_type_info) == 1:
                out_object = [out_object]

            http_resp_headers, out_string = apply_mtom(http_resp_headers,
                    out_string, ctx.descriptor.out_message._type_info.values(),
                    out_object)

        # initiate the response
        http_resp_headers['Content-Length'] = str(len(out_string))
        start_response(return_code, http_resp_headers.items())

        return [out_string]
コード例 #5
0
    def __handle_soap_request(self, req_env, start_response):
        ctx = soaplib.core.MethodContext()

        # implementation hook
        self.on_wsgi_call(req_env)

        in_string, in_string_charset = _reconstruct_soap_request(req_env)

        in_object = self.get_in_object(ctx, in_string, in_string_charset)

        return_code = HTTP_200
        if ctx.in_error:
            out_object = ctx.in_error
            return_code = HTTP_500
        else:
            assert ctx.service != None
            out_object = self.get_out_object(ctx, in_object)
            if ctx.out_error:
                out_object = ctx.out_error
                return_code = HTTP_500

        out_string = self.get_out_string(ctx, out_object)

        http_resp_headers = {
            'Content-Type': 'text/xml',
            'Content-Length': '0',
        }

        # implementation hook
        self.on_wsgi_return(req_env, http_resp_headers, out_string)

        if ctx.descriptor and ctx.descriptor.mtom:
            # when there are more than one return type, the result is
            # encapsulated inside a list. when there's just one, the result
            # is returned unencapsulated. the apply_mtom always expects the
            # objects to be inside an iterable, hence the following test.
            out_type_info = ctx.descriptor.out_message._type_info
            if len(out_type_info) == 1:
                out_object = [out_object]

            http_resp_headers, out_string = apply_mtom(
                http_resp_headers, out_string,
                ctx.descriptor.out_message._type_info.values(), out_object)

        # initiate the response
        http_resp_headers['Content-Length'] = str(len(out_string))
        start_response(return_code, http_resp_headers.items())

        return [out_string]