我正在使用twisted构建xml rpc服务,我想使用None,因为它可以在标准的python lib中完成.如何将allow_none传递给xmlrpc服务器的扭曲版本?
编辑
In [28]: sock = rpc.ServerProxy('http://localhost:7080',allow_none=True)
In [29]: sock
Out[29]: <ServerProxy for localhost:7080/RPC2>
In [30]: sock.list_reports()
Out[30]: ['example']
In [31]: sock.run_report('example')
---------------------------------------------------------------------------
Fault Traceback (most recent call last)
reports/<ipython console> in <module>()
/usr/lib/python2.6/xmlrpclib.pyc in __call__(self, *args)
1197 return _Method(self.__send, "%s.%s" % (self.__name, name))
1198 def __call__(self, *args):
-> 1199 return self.__send(self.__name, args)
1200
1201 ##
/usr/lib/python2.6/xmlrpclib.pyc in __request(self, methodname, params)
1487 self.__handler,
1488 request,
-> 1489 verbose=self.__verbose
1490 )
1491
/usr/lib/python2.6/xmlrpclib.pyc in request(self, host, handler, request_body, verbose) …Run Code Online (Sandbox Code Playgroud) 我打算写一个适配器类.在这个类中有一个xmlrpc-c服务器(深渊服务器).我想通过创建一个新线程来启动服务器,并且线程的功能是成员函数XMLThreadFun().
当我尝试使用下面的代码时,在适配器的构造函数实现的行上有一个错误:
/usr/include/boost/bind/bind.hpp:69:37: error: ‘void (Adapter::*)()’ is not a class, struct, or union type
Run Code Online (Sandbox Code Playgroud)
谁能告诉我如何解决这个错误,或者如何实现我的目标?对此,我真的非常感激.
以下是我的代码片段:
#ifdef _MSC_VER
#pragma warning( disable : 4503 4355 4786 )
#else
#include "config.h"
#endif
#include "quickfix/FileStore.h"
#include "quickfix/SocketInitiator.h"
#include "quickfix/SessionSettings.h"
#include "Application.h"
#include <string>
#include <iostream>
#include <fstream>
#include "quickfix/SessionID.h"
#include "quickfix/Session.h"
#include "getopt-repl.h"
#include <cassert>
#include <xmlrpc-c/base.hpp>
#include <xmlrpc-c/registry.hpp>
#include <xmlrpc-c/server_abyss.hpp>
#include <boost/thread.hpp>
#include <boost/date_time.hpp>
using namespace std;
class theClient : public xmlrpc_c::method {
public:
theClient() {}
theClient(FIX::SocketInitiator* initiator) {
set<FIX::SessionID> …Run Code Online (Sandbox Code Playgroud) 我变得疯狂,我无法弄清楚.
我已下载并尝试为iOS构建XMLRPC.我转向https://github.com/eczarny/xmlrpc和https://bitbucket.org/kdbdallas/xmlrpc-ios/wiki/Home 第一个,原始的,没有iOS目标.第二个应该有,但即使那个似乎也不起作用.
我使用XCode以下列方式构建XMLRPC-iOS lib:
当我建立自己的项目时,我得到:
ld:警告:忽略文件/Users/paulp/Documents/ios/iPhone/ios-account/Account/external/XMLRPC/libXMLRPC_iOS.a,文件是为归档而构建的,而不是被链接的体系结构(i386)未定义的体系结构符号i386:
"_ OBJC_CLASS _ $ _ XMLRPCRequest",引自:MyAPI.o中的objc-class-ref
"_OBJC_CLASS _ $ _ XMLRPCConnectionManager",引自:MyAPI.o中的objc-class-ref ld:未找到架构i386 clang的符号:错误:链接器命令失败,退出代码为1(使用-v查看调用)
怎么可能?XMLRPC-iOS设置设置为:
有人可以向我解释如何在我自己的应用程序中构建和使用XMLRPC-iOS库吗?谢谢!
很难找到与https一起使用的XMLRPC.net库的信息.
可以设置"https"URL的唯一文档是:http://xml-rpc.net/faq/xmlrpcnetfaq-2-5-0.html#2.3但是它没有准确解释如何正确设置.
在下载http://xmlrpcnet.googlecode.com/files/xml-rpc.net.2.5.0.zip中提供的样本基础上试验我试过这个:
StateNameServer解决方案的client.cs文件中的更改:
IStateName svr = (IStateName)Activator.GetObject(
typeof(IStateName), "https://localhost:5678/statename.rem");
Run Code Online (Sandbox Code Playgroud)
服务器代码是什么样的
IDictionary props = new Hashtable();
props["name"] = "MyHttpChannel";
props["port"] = 5678;
HttpChannel channel = new HttpChannel(
props,
null,
new XmlRpcServerFormatterSinkProvider()
);
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(StateNameServer),
"statename.rem",
WellKnownObjectMode.Singleton);
Run Code Online (Sandbox Code Playgroud)
当尝试使用HTTPS联系服务器时,客户端显然会丢弃异常,因为我不知道如何配置它.无论如何,有人可以帮忙吗?我应该寻找什么样的东西?
非常感谢 !
我正在从一个网站迁移到另一个使用Wordpress的网站.
我根据自己的需要创建了新的自定义类型(使用插件自定义帖子类型),并为每种自定义类型创建了类别.
然后我在Python中写下了一个脚本(改编自本文),它使用自3.4.x版以来支持的新的Wordpress XML-RPC API,从db获取帖子并在新的(测试)网站上远程推送它们.
目前我可以使用正确的帖子类型发布新帖子.但是如果我指定一个类别,wordpress总是会给我这个错误:
xmlrpclib.Fault: <Fault 401: 'Sorry, one of the given taxonomies is not supported by the post type.'>
Run Code Online (Sandbox Code Playgroud)
我确信给定的分类法支持帖子类型.我想我使用了错误的语法来指定类别ID.这是代码:
import datetime, xmlrpclib, MySQLdb
def post_remotely(post_data):
wp_url = "[my wordpress blog url]"
wp_username = "[myuser]"
wp_password = "[mypasswd]"
wp_blogid = "0"
status = 'publish'
server = xmlrpclib.ServerProxy(wp_url)
data = { 'post_title': post_data['title'], 'post_content': post_data['content'],
'post_date': post_data['data'], 'post_type': post_data['post_type'], 'terms': post_data['categories'],
'post_status': status }
post_id = server.wp.newPost(wp_blogid, wp_username, wp_password, data)
return post_id
Run Code Online (Sandbox Code Playgroud)
在调用者上,指定类别:
new_post['categories'] = [ …Run Code Online (Sandbox Code Playgroud) 我正在使用XMLRPC来发布Wordpress的帖子.我在发布缩略图时遇到问题,在调试wordpress代码后,我发现我的问题是由于图像没有附加到帖子这一事实引起的.我必须这样做而不需要修补wordpress或使用PHP,只需要使用XMLRPC.
我可以上传图片并获取图片的ID.让我感到困惑的另一点是你如何将图像附加到你尚未发布的帖子,因为你等待图片上传?我应该上传图片然后发布,然后使用图片ID和帖子ID对图像元数据做更新?
编辑:wordpress中有问题的代码就是这个检查
if ( $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'thumbnail' ) )
Run Code Online (Sandbox Code Playgroud)
我的假设是它失败了,因为图像是Unattached,如果我修复该代码一切都很好,但我无法修补我的应用程序用户的WP(所以这不是一个解决方案)
我可以通过管理页面将逗号分隔值(CSV)数据导入大多数模型.此过程处理外部ID,以便可以在以后的CSV导入中添加或修改数据.这是一种琐碎的行为.
通过API,可以创建和修改相同的记录,并可以设置外部ID.但是,这需要在使用API推送数据的外部应用程序中手动编码CSV导入器处理的许多逻辑.通过API推送数据可以实现自动化.
是否有一种方法可以使用API(因此不需要对Odoo中的代码进行任何更改)来推送CSV数据(因此插入/更新/关系/外部ID等的逻辑由Odoo处理)?这将是一种混合方法,我试图避免在Odoo中创建导入模块的需要.
编辑:"外部ID"通常称为"XML ID".我认为这是一个与早期版本的OpenERP相悖的术语,而不是与XML有关的任何内容.
此页面描述了一个load()函数,该函数通过管道将类似CSV的数据推送到系统中:
http://openerp-server.readthedocs.org/en/latest/06_misc_import.html
如果可能的话,我无法看到如何将该页面上的摘要转换为通过API的操作.我猜我需要接口(入口点),模型,方法(load()可能)和一些其他参数,但细节超出了我的范围.
我有一个实例化xmlrpclib.ServerProxy一次的应用程序,然后将其传递给多个线程(Web应用程序请求),这些线程同时执行XML/RPC调用.这适用于python 2.6.使用python 2.7,我们在多线程环境中遇到很多错误(ResponseNotReady,CannotSendRequest).
# This code works well in python 2.6, and breaks in python 2.7.
import xmlrpclib
import thread
proxy = xmlrpclib.ServerProxy("http://localhost:5000/")
def fetch_users():
print proxy.getUsers()
for _ in range(10):
thread.start_new_thread(fetch_users, ())
while(1):
pass
Run Code Online (Sandbox Code Playgroud)
这里有什么问题,是否有一种重新使用ServerProxy对象的线程安全方法?
我正在寻找一种通过Python以编程方式调用SOAP/RPC调用的简单方法.就像是:
method_to_invoke, args = parse_user_input()
outbound_xml = library.call_remote_method(method_to_invoke, args)
result = requests.post(... data=outbound_xml)
Run Code Online (Sandbox Code Playgroud)
我知道有几个 Python库支持SOAP/RPC调用; 然而,他们都做了一些"魔术",并允许这样的事情:
result = client.service.getPercentBodyFat('jeff', 68, 170)
Run Code Online (Sandbox Code Playgroud)
(前面的例子来自suds文档,但基本原理是相同的).这假设我提前知道方法的名称,并且无法在运行时确定它.
寻找解决方案,他们要么不再维护,要么尝试做太多"魔术".例如,看到这个过于复杂的问题或这个基本上是"构建你自己的XML并发送它"的解决方案.
是否有任何库可以为我构建"出站"XML而无需经历箍?我已经有一个HTTP服务器,它将接收入站RPC,并希望requests用于正确处理SSL证书验证等事情.