Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Savon 3 does not support soap operations without parameters. #477

Closed
matafc opened this issue Jul 3, 2013 · 6 comments
Closed

Savon 3 does not support soap operations without parameters. #477

matafc opened this issue Jul 3, 2013 · 6 comments

Comments

@matafc
Copy link

matafc commented Jul 3, 2013

Hi,

Savon 3 does not currently support soap operations without parameters. Savon 2 did, and it seems it is because the message xml is built with some default margins/indents, which creates whitespace where it is not needed. An operation message with no paramters should look like this:

<tns:say_hello></tns:say_hello>

Whereas Savon 3 creates it like so:

    <lol0:say_hello>
    </lol0:say_hello>

The whitespace it parsed and the soap server throws an error. I am using spyne to make the soap server. SoapUI and suds also create a compatible message, although of the form:

<spy:say_hello/>

Here is some sample output and my debug code:

savon2_test.rb:

require 'savon'
client = Savon.client(wsdl: "http://localhost:8000/?wsdl")
response = client.call(:say_hello, message: {})
puts 'response:', response.body
$ ruby savon2_test.rb
D, [2013-07-02T20:22:04.989008 #24055] DEBUG -- : HTTPI GET request to localhost (httpclient)
say_hello
I, [2013-07-02T20:22:05.007744 #24055]  INFO -- : SOAP request: http://localhost:8000/
I, [2013-07-02T20:22:05.007849 #24055]  INFO -- : SOAPAction: "say_hello", Content-Type: text/xml;charset=UTF-8, Content-Length: 305
D, [2013-07-02T20:22:05.007913 #24055] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="spyne.examples.hello" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><tns:say_hello></tns:say_hello></env:Body></env:Envelope>
D, [2013-07-02T20:22:05.008428 #24055] DEBUG -- : HTTPI POST request to localhost (httpclient)
I, [2013-07-02T20:22:05.013227 #24055]  INFO -- : SOAP response (status 200)
D, [2013-07-02T20:22:05.013682 #24055] DEBUG -- : <?xml version='1.0' encoding='UTF-8'?>
<senv:Envelope xmlns:tns="spyne.examples.hello" xmlns:senv="http://schemas.xmlsoap.org/soap/envelope/"><senv:Body><tns:say_helloResponse><tns:say_helloResult><tns:string>Hello, Tester</tns:string><tns:string>Hello, Tester</tns:string></tns:say_helloResult></tns:say_helloResponse></senv:Body></senv:Envelope>
response:
{:say_hello_response=>{:say_hello_result=>{:string=>["Hello, Tester", "Hello, Tester"]}}}

savon3_test.rb:

require 'savon'
client = Savon.new('http://localhost:8000/?wsdl')
op = client.operation('HelloWorldService', 'Application', 'say_hello')
op.body = {say_hello: {}}
puts 'message:', op.build
puts 'response:', op.call.inspect
$ ruby savon3_test.rb
message:
<env:Envelope xmlns:lol0="spyne.examples.hello" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Header>
  </env:Header>
  <env:Body>
    <lol0:say_hello>
    </lol0:say_hello>
  </env:Body>
</env:Envelope>
response:
#<Savon::Response:0x007f9229a785d8 @raw_response="<?xml version='1.0' encoding='UTF-8'?>\n<senv:Envelope xmlns:senv=\"http://schemas.xmlsoap.org/soap/envelope/\"><senv:Body><senv:Fault><faultcode>senv:Client.SchemaValidationError</faultcode><faultstring>&lt;string&gt;:5:0:ERROR:SCHEMASV:SCHEMAV_CVC_COMPLEX_TYPE_2_1: Element '{spyne.examples.hello}say_hello': Character content is not allowed, because the content type is empty.</faultstring><faultactor></faultactor></senv:Fault></senv:Body></senv:Envelope>">

I removed the indent and margin arguments from Builder::XmlMarkup.new() in lib/savon/message.rb:16 and lib/savon/envelope.rb:52 and ran it again.

$ ruby savon3_test.rb
message:
<env:Envelope xmlns:lol0="spyne.examples.hello" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header></env:Header><env:Body><lol0:say_hello></lol0:say_hello></env:Body></env:Envelope>
response:
#<Savon::Response:0x007f9b91dfa398 @raw_response="<?xml version='1.0' encoding='UTF-8'?>\n<senv:Envelope xmlns:tns=\"spyne.examples.hello\" xmlns:senv=\"http://schemas.xmlsoap.org/soap/envelope/\"><senv:Body><tns:say_helloResponse><tns:say_helloResult><tns:string>Hello, Tester</tns:string><tns:string>Hello, Tester</tns:string></tns:say_helloResult></tns:say_helloResponse></senv:Body></senv:Envelope>">

Can this be fixed by using my changes, or perhaps by adding a flag to turn off the pretty formatting of the xml builder? It seems many of your tests expect the message to be in that format, so I can understand wanting to do the latter.

Thanks!

@rubiii
Copy link
Contributor

rubiii commented Jul 3, 2013

thanks for reporting @matafc. you're right, i think there is no spec for an operation without arguments yet.
i'll take a look at this later today.

@rubiii
Copy link
Contributor

rubiii commented Jul 3, 2013

happy to see you using version 3, but i feel like i have to warn you that you're using an unstable version.
so things might change pretty rapidly once i find some time to continue working on this version.
guess you know that already, but ... :)

@rubiii
Copy link
Contributor

rubiii commented Jul 3, 2013

i'm trying to get savon v2.3.0 released and will come back to this after that.

@rubiii
Copy link
Contributor

rubiii commented Jul 5, 2013

can you provide the wsdl of you service as a gist or pastie?

@matafc
Copy link
Author

matafc commented Jul 6, 2013

Sure, I modified an example from the spyne website to show the behavior:

https://gist.github.com/matafc/5941570

@rubiii rubiii closed this as completed in 5c10c9f Jul 13, 2013
@rubiii
Copy link
Contributor

rubiii commented Jul 13, 2013

thanks @matafc. pushed a fix for this to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants