Table Of Contents

Previous topic

Client Transports

Next topic

Auxiliary Processors

This Page

Server Transports

Server Base Class

class spyne.server._base.ServerBase(app)[source]

This class is the abstract base class for all server transport implementations. Unlike the client transports, this class does not define a pure-virtual method that needs to be implemented by all base classes.

If there is a call to start the main loop, it’s conventionally called serve_forever().

generate_contexts(ctx, in_string_charset=None)[source]

Calls create_in_document and decompose_incoming_envelope to get method_request string in order to generate contexts.

get_in_object(ctx)[source]

Uses the ctx.in_string to set ctx.in_body_doc, which in turn is used to set ctx.in_object.

get_out_object(ctx)[source]

Calls the matched method using the ctx.in_object to get ctx.out_object.

get_out_string(ctx)[source]

Uses the ctx.out_object to set ctx.out_document and later ctx.out_object.

serve_forever()[source]

Implement your event loop here.

transport = None

The transport type, conventionally defined by the URI string to its definition.

HTTP (WSGI)

A server transport uses http as transport, and wsgi as bridge api.

class spyne.server.wsgi.WsgiApplication(app, chunked=True, max_content_length=2097152, block_length=8192)[source]

A PEP-3333 compliant callable class.

Supported events:
  • wsdl

    Called right before the wsdl data is returned to the client.

  • wsdl_exception

    Called right after an exception is thrown during wsdl generation. The exception object is stored in ctx.transport.wsdl_error attribute.

  • wsgi_call

    Called first when the incoming http request is identified as a rpc request.

  • wsgi_return

    Called right before the output stream is returned to the WSGI handler.

  • wsgi_error

    Called right before returning the exception to the client.

  • wsgi_close

    Called after the whole data has been returned to the client. It’s called both from success and error cases.

decompose_incoming_envelope(prot, ctx, message)[source]

This function is only called by the HttpRpc protocol to have the wsgi environment parsed into ctx.in_body_doc and ctx.in_header_doc.

generate_contexts(ctx, in_string_charset=None)

Calls create_in_document and decompose_incoming_envelope to get method_request string in order to generate contexts.

generate_map_adapter(ctx)[source]
get_in_object(ctx)

Uses the ctx.in_string to set ctx.in_body_doc, which in turn is used to set ctx.in_object.

get_out_object(ctx)

Calls the matched method using the ctx.in_object to get ctx.out_object.

get_out_string(ctx)

Uses the ctx.out_object to set ctx.out_document and later ctx.out_object.

handle_error(p_ctx, others, error, start_response)[source]
handle_rpc(req_env, start_response)[source]
has_patterns[source]
serve_forever()

Implement your event loop here.

transport = 'http://schemas.xmlsoap.org/soap/http'
class spyne.server.wsgi.WsgiMethodContext(transport, req_env, content_type)[source]

The WSGI-Specific method context. WSGI-Specific information is stored in the transport attribute using the WsgiTransportContext class.

descriptor
frozen = False
get_descriptor()
method_name

The public name of the method the method_request_string was matched to.

set_descriptor(descriptor)
transport = None

Holds the WSGI-specific information

class spyne.server.wsgi.WsgiTransportContext(transport, req_env, content_type)[source]

The class that is used in the transport attribute of the WsgiMethodContext class.

content_type
get_mime_type()
mime_type
req_env = None

WSGI Request environment

req_method = None

HTTP Request verb, as a convenience to users.

set_mime_type(what)

ZeroMQ

The spyne.server.zeromq module contains a server implementation that uses ZeroMQ (zmq.REP) as transport.

class spyne.server.zeromq.ZeroMQServer(app, app_url, wsdl_url=None)[source]

The ZeroMQ server transport.

generate_contexts(ctx, in_string_charset=None)

Calls create_in_document and decompose_incoming_envelope to get method_request string in order to generate contexts.

get_in_object(ctx)

Uses the ctx.in_string to set ctx.in_body_doc, which in turn is used to set ctx.in_object.

get_out_object(ctx)

Calls the matched method using the ctx.in_object to get ctx.out_object.

get_out_string(ctx)

Uses the ctx.out_object to set ctx.out_document and later ctx.out_object.

serve_forever()[source]

Runs the ZeroMQ server.

transport = 'http://rfc.zeromq.org/'
class spyne.server.zeromq.ZmqMethodContext(app)[source]
descriptor
frozen = False
get_descriptor()
method_name

The public name of the method the method_request_string was matched to.

set_descriptor(descriptor)
spyne.server.zeromq.context = <zmq.sugar.context.Context object at 0x343e6e0>

The ZeroMQ context.

NullServer

The spyne.server.null module contains the NullServer class and its helper objects.

The name comes from the “null modem connection”. Look it up.

class spyne.server.null.NullServer(app)[source]

A server that doesn’t support any transport at all – it’s implemented to test services without having to run a server.

It implicitly uses the ‘sync’ auxiliary processing mode.

Note that:
  1. **kwargs overwrite *args.

  2. You can do:

    logging.getLogger('spyne.server.null').setLevel(logging.CRITICAL)
    

to hide context delimiters in logs.

generate_contexts(ctx, in_string_charset=None)

Calls create_in_document and decompose_incoming_envelope to get method_request string in order to generate contexts.

get_in_object(ctx)

Uses the ctx.in_string to set ctx.in_body_doc, which in turn is used to set ctx.in_object.

get_out_object(ctx)

Calls the matched method using the ctx.in_object to get ctx.out_object.

get_out_string(ctx)

Uses the ctx.out_object to set ctx.out_document and later ctx.out_object.

get_wsdl()[source]
serve_forever()

Implement your event loop here.

set_options(**kwargs)[source]
transport = 'noconn://null.spyne'