divan / gorilla-xmlrpc

Gorilla XML RPC implementation (Golang/Go)
BSD 3-Clause "New" or "Revised" License
69 stars 59 forks source link

Serve/define XML-RPC methods without namespacing to a class/struct? #14

Closed daluu closed 7 years ago

daluu commented 8 years ago

Hi,

Great project. I'm a novice at go, and looking at your example usage in the README, as well as the unit tests for gorilla/rpc, it looks like the class/struct is prefixed as namespace to the XML-RPC method being called/requested. For my particularly use case, the RPC method names are not "prefixed" with a class/namespace, but rather being global, so just a method name to call. e.g. call "say" or "Say" instead of "HelloService.Say".

I understand namespace is useful/necessary when serving from multiple structs or packages, but in my case, it would be a single one, so there's no ambiguity. And for my use case, the "client" is expecting to make the XML-RPC call without a namespace, so I don't have leeway to accommodate namespacing in the RPC request. Is there an option or way to make the RPC call omitting the namespace, more like just use a "global" namespace? I submitted a duplicate issue to https://github.com/gorilla/rpc/issues/48 in case it's really more about gorilla/rpc than your XML extension of it.

For some background/history, the XML-RPC server I intend to build is serving multiple namespaced methods via use of reflection through a single wrapper class. I've done this same thing in other XML-RPC server implementations (for other languages, e.g. Perl, PHP, Java, .NET), would like to do for go now. The server I'm trying to build is a go implementation for https://github.com/robotframework/RemoteInterface, with the Python version being the reference implementation.

daluu commented 8 years ago

I guess for my particular case, an interim solution may be to patch this package's code to prepend the service package name (since it will be missing in the XML-RPC request) when passing on the data after the XML unmarshal process, if that would even work.

Shark commented 8 years ago

There's a method RegisterAlias:

xmlrpcCodec := xml.NewCodec()
xmlrpcCodec.RegisterAlias("call", "System.Multicall")

Maybe this one already does everything you need...

daluu commented 7 years ago

Thanks, that seems to do the trick :)