overridding namespace prefixes in wsdl mode

483 views
Skip to first unread message

dub...@gmail.com

unread,
Jun 14, 2013, 5:03:15 PM6/14/13
to sav...@googlegroups.com
So I want to use my own namespace prefixes for elements in Savon but it seems I cannot.
When the Savon client parses my WSDL (builder.rb), it creates a number namespaces with internally generated prefixes and I have no way of overriding the prefix.  If I ever want to apply attributes to xml elements from one of those namespaces, I have to make sure I know what internally generated prefix to use in my element.

I know I can pass a Hash of namespaces (prefix and uri) as a global option, but it seems that these only get added to the soap envelope when the used wsdl namepaces get merged with the global namespaces.

It seems that Savon makes no attempt to match the namespace uri used in the wsdl with the namespaces I define in the global namespaces.

Is there any way around this?


rubiii

unread,
Jul 2, 2013, 2:16:46 PM7/2/13
to sav...@googlegroups.com, dub...@gmail.com
hi,

there is no offical way to change those identifiers, because they're meaninless.
it's the value that you have to look at. i know there are services/tools which get this wrong,
but it's not worth supporting those.

if you need to control the namespace identifiers, you can use savon version 2 without a wsdl.
gyoku (https://github.com/savonrb/gyoku) allows you to specify your own namespace identifiers
in the request hash and savon allows you to set your own namespaces.

so you definitely make it work, but i'm not sure it's worth it.

cheers,
daniel

dub...@gmail.com

unread,
Jul 2, 2013, 7:50:24 PM7/2/13
to sav...@googlegroups.com
Well I realize that there is no way around this, but I was hoping I could make a feature request for it. Where could I do that?
Using wsdl mode is very helpful because I don't have to specify a lot of the details in my soap calls, but there have been times I need to apply attributes to some of the xml elements before the request is sent. Like I said, in these cases, if I don't know the "randomly generated" namespace prefix beforehand, its not possible.
If I could specify the prefixes that the client uses before the wsdl is parsed, I would be able to apply attributes to xml elements with certainty.

rubiii

unread,
Jul 3, 2013, 3:24:13 AM7/3/13
to sav...@googlegroups.com, dub...@gmail.com
interesting problem. if you file an issue with savon and give it a descriptive description to work with,
i will come up with a working solution for version 3. i don't think it's worth to implement this for version 2.


cheers,
daniel

Andy Holland

unread,
Aug 14, 2013, 8:30:31 AM8/14/13
to sav...@googlegroups.com, dub...@gmail.com
Hi, I know this is an old topic, but I recently had the same problem, I managed to eliminate the default namespaces by placing http://pastebin.com/F5t2HqGb in lib/savon/builder.rb, you also need to ensure that lib is in your autoload path (config.autoload_paths += %W(#{config.root}/lib) in config/application.rb) 

@rubiiiI know that a SOAP API shouldn't break because of this, but I have no control over that.
Reply all
Reply to author
Forward
0 new messages