2010-11-04 75 views
0

我想在我的Flex應用程序和我的XMLRPC Python服務器之間使用XMLRPC機制。帶有XMLRPC Python服務器的AS3 RemoteObject:「NetConnection.Call.BadVersion」問題

我的服務器:

class ServerMockUp(SimpleXMLRPCRequestHandler): 
# Services path declaration 
rpc_paths =() 

myServer = SimpleXMLRPCServer(("localhost", 80), 
         requestHandler=ServerMockUp, 
         logRequests=True) 

def isUserAuthenticated(key, time): 
    print "[loginService > isUserAuthenticated]" 
    print ":key='%s' :time=%d" %(key, time)  
    return True 

if __name__ == '__main__': 
    # Services registration 
    myServer.register_function(isUserAuthenticated) 
    myServer.register_introspection_functions() 
    # Start server ... 
    myServer.serve_forever() 

我services-config.xml文件:

... 
    <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel"> 
     <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/> 
    </channel-definition> 
    ... 

,這是出現連接錯誤:

faultCode:Client.Error.MessageSend faultString:'Send failed' faultDetail:'Channel.Connect.Failed error NetConnection.Call.BadVersion: : url: 'http://localhost/MyApp/messagebroker/amf'' 

當調試我XMLRPC服務器,例外情況是(在SimpleXMLRPCServer類中):

params, method = xmlrpclib.loads(data) 

錯誤:

str: <?xml version='1.0'?> 
<methodResponse> 
<fault> 
<value><struct> 
<member> 
<name>faultCode</name> 
<value><int>1</int></value> 
</member> 
<member> 
<name>faultString</name> 
<value><string>&lt;class 'xml.parsers.expat.ExpatError'&gt;:not well-formed (invalid token): line 1, column 0</string></value> 
</member> 
</struct></value> 
</fault> 
</methodResponse> 

非常感謝您的幫助!

問候

安東尼

回答

0

或許這是與objectEncoding

嘗試設置它來AMF0:

nc.defaultObjectEncoding = ObjectEncoding.AMF0; 

只需連接之前。