简体   繁体   English

Soaplib连接-msg's0:FunctionName',未找到

[英]Soaplib connection - msg 's0:FunctionName', not-found

I have problem with solution that was working very good and suddenly it stopped to do so. 我的解决方案存在问题,该解决方案工作得非常好,突然停下来了。 I wrote server/client scripts and modules to make a SOAP connection type for my application. 我编写了服务器/客户端脚本和模块来为我的应用程序创建SOAP连接类型。 Here is my server code : 这是我的服务器代码:

import os
import rsglobal
import signal
import soaplib
from soaplib.core.service import rpc, DefinitionBase, soap
from soaplib.core.model.primitive import String, Integer
from soaplib.core.server import wsgi
from soaplib.core.model.clazz import Array

try:
    import psycopg
except:
    import psycopg2 as psycopg

import rssql

LogFile = "serwer_soap.log"


#-##############################################################################
#-- SOAP SERVER CLASS
#-##############################################################################

class AnakondaSOAPServer(DefinitionBase):

    #-##############################################################################
    #-- SOAP FUNCTIONS
    #-##############################################################################

    @soap(String,Integer,_returns=Array(String))
    def say_hello(self,name,times):
        results = []
        for i in range(0,times):
            results.append('Hello, %s'%name)
        return results

    @soap(String,String,_returns=String)
    def ConnectToBase(self,name,passwd):
        global PolSQL
        try:
            stat = 'OK'
            dane=[]
            PolSQL=rssql.RSSQL()

            if PolSQL.ConnectToSQL(name,passwd,'127.0.0.1',5432,'','databasename')==1:
                stat = u'Connection Error'

            SQL='SELECT * FROM table1;'
            stat,dane,dump,dump=PolSQL.Execute(SQL,3)
        except Exception,e:
            return u'Connection Error '+str(e)

        return stat+' '+str(dane)

    @soap(_returns=String)
    def GiveData(self):
        global PolSQL
        try:
            stat = 'OK'
            dane=[]
            SQL='SELECT * FROM table1;'
            stat,dane,dump,dump=PolSQL.Execute(SQL,3)
        except Exception,e:
            return u'Data getting error '+str(e)

        return stat+' '+str(dane)

    #------------------------------------------
    # ADMINISTRATIVE FUNCTIONS
    #------------------------------------------

    def SetDefaultData(self):
        self._oldHupHandler = signal.SIG_DFL
        self._oldAlarmHandler = signal.SIG_DFL
        self._oldTermHandler = signal.SIG_DFL
        self._childProcess = None
        self.PolSQL = None

#-------------------------------------------------------------------------------

    def _OnSIGALRM(self, sig, frame):
        pass

#-------------------------------------------------------------------------------

    def _OnSIGHUP(self, sig, frame):
        if self._childProcess:
            os.kill(self._childProcess, signal.SIGHUP)
        else:
            pass

#-------------------------------------------------------------------------------

    def _OnSIGTERM(self, sig, frame):
        pass

#-------------------------------------------------------------------------------

    def _exit(self, status):
        if self.PolSQL:
            self.PolSQL.DisconnectSQL()
        if status:
            rsglobal.Log(u"SOAP - finishing : "+str(status), 1)
        os._exit(status)

#-------------------------------------------------------------------------------

    def StartSOAPServer(self, dbspec,HostSOAP,PortSOAP):
        import os

        self.dbspec = dbspec
        childPID = os.fork()
        if childPID:
            self._childProcess = childPID
            return childPID
        else:
            try:
                signal.signal(signal.SIGUSR1, signal.SIG_DFL)
                signal.signal(signal.SIGCHLD, signal.SIG_DFL)
                if LogFile:
                    rsglobal.LogFile = LogFile

                self._oldHupHandler = signal.signal(signal.SIGHUP, lambda x, y: self._OnSIGHUP(x, y))
                self._oldAlarmHandler = signal.signal(signal.SIGALRM, lambda x, y: self._OnSIGALRM(x, y))
                self._oldTermHandler = signal.signal(signal.SIGTERM, lambda x, y: self._OnSIGTERM(x, y))
                self.PolSQL = SQLConnect(self.dbspec)

                # running SOAP server
                from wsgiref.simple_server import make_server
                ServiceSoap = soaplib.core.Application([AnakondaSOAPServer],'AnakSOAP',name='AnakSOAP')
                WSGI = wsgi.Application(ServiceSoap)
                Serwer = make_server(HostSOAP, int(PortSOAP), WSGI)
                Serwer.serve_forever()

            except Exception, exc:
                rsglobal.ZapiszDoLogow(u"Server SOAP Error : "+str(exc), 2)
                self._exit(1)

#-------------------------------------------------------------------------------

    def StopSOAPServer(self):
        if self._childProcess:
            os.kill(self._childProcess, signal.SIGTERM)

#-##################################################################


#-### - This is main SOAP server object used in other modules
SerwerSOAP = AnakondaSOAPServer()
SerwerSOAP.SetDefaultData()

#-##############################################################################
#-## ADDITIONAL FUNCTIONS
#-##############################################################################

def SQLConnect(dbspec):
    # creates connection to database

    PolSQL = rssql.RSSQL()
    dbuser, dbpass, dbhost, dbport, dbase = dbspec
    if PolSQL.PolaczZSQL(dbuser, dbpass, dbhost, dbport, None, Baza=dbase):
        return False
    else:
        return PolSQL

My client code (which just tests server) is like this : 我的客户端代码(仅测试服务器)如​​下所示:

from suds.client import Client

hello_client = Client('http://128.1.2.3:1234/AnakondaSOAPServer?wsdl')

hello_client.options.cache.clear()

result = hello_client.service.ConnectToBase("username", "password")
print 'Result1',result
result = hello_client.service.GiveData()
print 'Result2',result

Earlier in my main application i use function StartSOAPServer with proper parameters and it's waiting for connections. 在我的主应用程序中,我先前使用带有适当参数的功能StartSOAPServer,并且它正在等待连接。 I can see it with netstat on good adress and port. 我可以用netstat在良好的地址和端口上看到它。

After running client script i get : 运行客户端脚本后,我得到:

Traceback (most recent call last):
  File "./testsoapclient.py", line 8, in <module>
    hello_client = Client('http://128.1.2.3:1234/AnakondaSOAPServer?wsdl')
  File "/usr/local/lib/python2.6/dist-packages/suds-0.4-py2.6.egg/suds/client.py", line 112, in __init__
    self.wsdl = reader.open(url)
  File "/usr/local/lib/python2.6/dist-packages/suds-0.4-py2.6.egg/suds/reader.py", line 152, in open
    d = self.fn(url, self.options)
  File "/usr/local/lib/python2.6/dist-packages/suds-0.4-py2.6.egg/suds/wsdl.py", line 158, in __init__
    self.resolve()
  File "/usr/local/lib/python2.6/dist-packages/suds-0.4-py2.6.egg/suds/wsdl.py", line 207, in resolve
    c.resolve(self)
  File "/usr/local/lib/python2.6/dist-packages/suds-0.4-py2.6.egg/suds/wsdl.py", line 494, in resolve
    raise Exception("msg '%s', not-found" % op.input)
Exception: msg 's0:ConnectToBase', not-found

Earlier i had problem with visibility of functions after creating a SOAP connection. 早些时候,在创建SOAP连接后,我对功能的可见性存在疑问。 Solution was to clear a cache. 解决的办法是清除缓存。 Now i can't even create it. 现在我什至无法创建它。 I use python 2.6, and lately my main app was transfered from 2.4 to 2.6. 我使用python 2.6,最近我的主应用程序从2.4转移到2.6。 It's the only difference i can think of. 这是我能想到的唯一区别。

I tried manipulate with soaplib.core.Application definition, but it didn't work. 我尝试用soaplib.core.Application定义进行操作,但是没有用。

Please help :) 请帮忙 :)

I managed to overcome the problems and it's working again. 我设法克服了这些问题,并且它再次起作用。 First thing that repairs situation is splitting server into 2 classes - one to create object and run SOAPServer and second - SOAPServer which contains only definitions of functions. 修复情况的第一件事是将服务器分为两类-一类用于创建对象并运行SOAPServer,第二类-SOAPServer仅包含功能定义。

Even after doing this changes i had bad results. 即使进行了此更改,我也有不好的结果。 I found out, that damaged structure of server definition hides in /tmp/suds directory (and that is why it was working while having damaged code before). 我发现,服务器定义的损坏结构隐藏在/ tmp / suds目录中(这就是为什么它之前损坏代码时仍在工作的原因)。 Deleting this files allowed to refresh this structure and all scripts started to work again. 删除此文件可以刷新此结构,并且所有脚本都可以再次开始工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flask-restful 未找到蓝图处理 - Flask-restful not-found handling for blueprint AttributeError: &#39;float&#39; 对象没有属性 &#39;S0&#39; - AttributeError: 'float' object has no attribute 'S0' 对于soaplib 库安装,Pip 安装失败并显示“连接错误” - Pip install fails with “connection error" for soaplib library installation Python 在 Pandas 数据框中创建与现有列中找到/未找到的行值匹配的列 - Python Create Column in Pandas Data Frame That Matches Row for Row Values Found / Not-Found in Existing Column InvalidSchema(&quot;没有为 &#39;%s&#39; 找到连接适配器&quot; % url) - InvalidSchema("No connection adapters were found for '%s'" % url) InvalidSchema(“找不到&#39;%s&#39;”%url的连接适配器) - InvalidSchema(“No connection adapters were found for '%s'” % url) 过滤器图描述 [0][1]concat=a=1:n=1:v=1[s0] 中的 Stream 说明符 '' 不匹配任何流 - Stream specifier '' in filtergraph description [0][1]concat=a=1:n=1:v=1[s0] matches no streams ffmpeg-python Stream filtergraph 描述 [0]concat=n=1[s0] 中的说明符 '' 不匹配任何流 - ffmpeg-python Stream specifier '' in filtergraph description [0]concat=n=1[s0] matches no streams 具有默认参数的Soaplib函数 - Soaplib functions with default arguments Python soaplib和Django - Python soaplib and Django
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM