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

wsdl file that worked fine with soap4r produces not working code with soap4r-spox #7

Open
neigesdantan opened this issue Aug 30, 2013 · 1 comment

Comments

@neigesdantan
Copy link

a wsdl file that works with soap4r produces not working server and client stubs with soap4r-spox.

wsdl file is:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.com/example/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="example" targetNamespace="http://www.example.com/example/">
  <wsdl:types>
    <xsd:schema targetNamespace="http://www.example.com/example/">
      <xsd:element name="param" type="xsd:string">
      </xsd:element>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="request">
    <wsdl:part name="msg" type="xsd:string"/>
  </wsdl:message>
  <wsdl:message name="response">
    <wsdl:part name="msg" type="xsd:string"/>
  </wsdl:message>
  <wsdl:portType name="port">
    <wsdl:operation name="op">
      <wsdl:input message="tns:request"/>
      <wsdl:output message="tns:response"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="bin" type="tns:port">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="op">
      <soap:operation soapAction="http://www.example.com/example/op"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="example">
    <wsdl:port binding="tns:bin" name="bin">
      <soap:address location="http://localhost:10080"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

how to reproduce:

  • install ruby 1.8.7 (ruby 1.9.3 produces the same result)
  • install rubygem
  • install gem soap4r-spox
  • generate client with:
wsdl2ruby.rb --wsdl case1.wsdl --type client --force
  • execute client with:
ruby -rubygems -e 'gem "soap4r-spox"' -e 'require "exampleClient"' 

result is:

C:/Ruby187/lib/ruby/gems/1.8/gems/soap4r-spox-1.6.0/lib/soap/element.rb:113:in `initialize': undefined method `name' for nil:NilClass (NoMethodError)
    from C:/Ruby187/lib/ruby/gems/1.8/gems/soap4r-spox-1.6.0/lib/soap/element.rb:112:in `each'
    from C:/Ruby187/lib/ruby/gems/1.8/gems/soap4r-spox-1.6.0/lib/soap/element.rb:112:in `initialize'
    from C:/Ruby187/lib/ruby/gems/1.8/gems/soap4r-spox-1.6.0/lib/soap/rpc/proxy.rb:126:in `new'
    from C:/Ruby187/lib/ruby/gems/1.8/gems/soap4r-spox-1.6.0/lib/soap/rpc/proxy.rb:126:in `call'
    from C:/Ruby187/lib/ruby/gems/1.8/gems/soap4r-spox-1.6.0/lib/soap/rpc/driver.rb:151:in `call'
    from (eval):6:in `op'
    from ./exampleClient.rb:20
    from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from -e:2

changing the wsdl and using element instead of type in messages definition

  <wsdl:message name="request">
    <wsdl:part name="msg" element="tns:param"/>
  </wsdl:message>
  <wsdl:message name="response">
    <wsdl:part name="msg" element="tns:param"/>
  </wsdl:message>

produces a client stub that works. the request sent is:

POST / HTTP/1.1
SOAPAction: "http://www.example.com/example/op"
Content-Type: text/xml; charset=utf-8
User-Agent: SOAP4R/1.6.1-SNAPSHOT (2.3.4.1, ruby 1.8.7 (2013-06-27))
Accept: */*
Date: Fri, 30 Aug 2013 09:04:36 GMT
Content-Length: 350
Host: localhost:10080

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Body>
    <n1:param xmlns:n1="http://www.example.com/example/"
        xsi:nil="true"></n1:param>
  </env:Body>
</env:Envelope>

using soap4r instead of soap4r-spox and the original wsdl produces a client that works. the request sent is:

POST / HTTP/1.1
SOAPAction: "http://www.example.com/example/op"
Content-Type: text/xml; charset=utf-8
User-Agent: SOAP4R/1.5.8 (2.3.4.1, ruby 1.8.7 (2013-06-27))
Accept: */*
Date: Fri, 30 Aug 2013 08:35:04 GMT
Content-Length: 289
Host: localhost:10080

<?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:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Body>
    <msg xsi:nil="true"></msg>
  </env:Body>
</env:Envelope>

generated code is pratically the same with soap4r and soap4r-spox. in fact code generated with soap4r-spox works correctly using soap4r gem after a minor fix of

illegal inout definition for document style

in exampleDriver.rb line 12 ( it just needs string instead of symbol for :in and :out)

after the fix the request sent is:

POST / HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://www.example.com/example/op"
User-Agent: SOAP4R/1.5.8 (2.3.4.1, ruby 1.8.7 (2013-06-27))
Accept: */*
Date: Fri, 30 Aug 2013 09:17:32 GMT
Content-Length: 289
Host: localhost:10080

<?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:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Body>
    <msg xsi:nil="true"></msg>
  </env:Body>
</env:Envelope>
@neigesdantan
Copy link
Author

I tracked down the problem:
In lib / soap / rpc / methodDef.rb

at line 42

      if nsdef && namedef
        qname = XSD::QName.new(nsdef, namedef)
      else
        qname = nil
      end

qname is nil if nsdef is nil. this prevents SOAPString#@elenaME from being assigned.
Using the mentioned wsdl nsdef is in fact nil.

I think that checking if nsdef is nil is not necessary and can safely be removed.
Any advice against doing so?

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

No branches or pull requests

1 participant