log.error("Not jsonrpc-2.0 request.")
        return Response(response="Expected jsonrpc 2.0 request.", status=400)
    methods_map = _initialize_map()
    method_name = body.get("method")
    if method_name not in methods_map:
        log.error("Unrecognized method: %s.", method_name)
        return Response(response=f"Unrecognized method: {method_name}.", status=400)
    handler = methods_map[method_name]
    params = {}
    try:
        if body.get("params"):
            params_json = json.loads(str(body.get("params")))
            params = BaseSerialization.deserialize(params_json, use_pydantic_models=True)
    except Exception as e:
        log.error("Error when deserializing parameters for method: %s.", method_name)
        log.exception(e)
        return Response(response="Error deserializing parameters.", status=400)
    log.debug("Calling method %s.", method_name)
    try:
        
        with create_session() as session:
            output = handler(**params, session=session)
            output_json = BaseSerialization.serialize(output, use_pydantic_models=True)
            response = json.dumps(output_json) if output_json is not None else None
            return Response(response=response, headers={"Content-Type": "application/json"})
    except Exception as e:
        log.error("Error executing method: %s.", method_name)
        log.exception(e)
        return Response(response=f"Error executing method: {method_name}.", status=500)