TypeError:无法在pysimplesoap库中将'bytes'对象隐式转换为str

时间:2018-09-19 22:29:37

标签: python-3.x mod-wsgi apache2.4 windows-server-2016 pysimplesoap

我正在将Windows 2016 Server与Apache 2.4.34(Apache Lounge发行版)一起使用。我在python 3.4中有一个SOAP服务,装有mod_wsgi库。服务器收到请求后,Apache错误日志中将显示下一条消息:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

[self initFirebase];

return YES;
}

我在其他服务器上可以使用相同的环境,但是在这里我遇到了这个问题,使我迷失了2天。该错误不在我的代码中,它仅在请求到达apache服务器并将其传递给python代码时发生。

这是SOAP Dispatcher声明:

mod_wsgi (pid=2600): Exception occurred processing WSGI script 'C:/Apache24/cgi-bin/wstsibio5/wstsibio5.wsgi'.
Traceback (most recent call last):\r
  File "C:\\Python34\\lib\\site-packages\\pysimplesoap\\server.py", line 163, in dispatch\r
    ns = NS_RX.findall(xml)\r
TypeError: can't use a string pattern on a bytes-like object\r
\r
During handling of the above exception, another exception occurred:\r
\r
Traceback (most recent call last):\r
  File "C:\\Python34\\lib\\site-packages\\pysimplesoap\\server.py", line 499, in __call__\r
    return self.handler(environ, start_response)\r
  File "C:\\Python34\\lib\\site-packages\\pysimplesoap\\server.py", line 505, in handler\r
    return self.do_post(environ, start_response)\r
  File "C:\\Python34\\lib\\site-packages\\pysimplesoap\\server.py", line 532, in do_post\r
    response = self.dispatcher.dispatch(request)\r
  File "C:\\Python34\\lib\\site-packages\\pysimplesoap\\server.py", line 211, in dispatch\r
    detail += '\\n\\nXML REQUEST\\n\\n' + xml\r
TypeError: Can't convert 'bytes' object to str implicitly\r

这是注册的功能。还有其他一些,但是它们取决于这一响应:

ws = SoapDispatcher(
     'my_dispatcher',
     location="http://localhost:" + str(puerto) + "/",
     action="http://localhost:" + str(puerto) + "/",  # SOAPAction
     namespace="http://localhost:" + str(puerto) + "/wstsibio4.wsdl",
     prefix="ns0",
     trace=True,
     pretty=True,
     debug=True,
     ns=True)

以防万一,脚本的导入:

ws.register_function('Presente', presente,
                     returns={'Respuesta': SimpleXMLElement},
                     args={'id': int, 'serie': str, 'codigo': int, 'mac': str, 'ip': str,
                           'reg_marc': int, 'huellas': int, 'huellas_nuevas': int, 'huellas_modificadas':int,
                           'huellas_eliminadas':int, 'operacion': int, 'mensaje': str, 'fecha_hora': str})

请帮助。我知道这是可行的,在向客户端说出他的服务器是问题之前,我需要一些参数。

厄瓜多尔的问候:-D

0 个答案:

没有答案