Forum: Ruby Problem with soap and wsdl ..

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
71477e5162d702dae2a072d66a855fec?d=identicon&s=25 Larz (Guest)
on 2008-12-05 16:05
(Received via mailing list)
If anyone can help me figure this out, I'd appreciate it. I'm trying
to do soap calls to a a condor web service.
Some of the calls work ok, but below I try to call commitTransaction
and it gets an error. Then below there is a second attempt using wsdl,
but that fails also in some other way ...

================================


require 'soap/rpc/driver'

drv = SOAP::RPC::Driver.new('http://133.24.112.97:63962',
'urn:condor')

drv.add_method('beginTransaction','duration')
drv.add_method('commitTransaction','transaction','two')

p drv

res = drv.beginTransaction(20)

p res
p res.transaction

#p res.status.code

sleep 2

id = res.transaction.id.to_i

p id.class

stat = drv.commitTransaction(id,{'id' => id, 'duration' => 20})
p stat


#<SOAP::RPC::Driver:#<SOAP::RPC::Proxy:http://133.24.112.97:63962>>
#<SOAP::Mapping::Object:0x..fdbec7498 {}status=#<SOAP::Mapping::Object:
0x..fdbec72c2 {}code="SUCCESS" {}message="Success"> {}
transaction=#<SOAP::Mapping::Object:0x..fdbec6d36 {}id="960467459" {}
duration="20">>
#<SOAP::Mapping::Object:0x..fdbec6d36 {}id="960467459" {}
duration="20">
Fixnum
: Validation constraint violation: data type mismatch xsd:int in
element <transaction> (SOAP::FaultError)


The error here occurs at the commitTransaction call ...

==========================================

Here is what Transaction and commitTransaction looks like in wsdl:

<complexType name="Transaction">
-
<sequence>
<element name="id" type="xsd:int" minOccurs="0" maxOccurs="1"/>
<element name="duration" type="xsd:int" minOccurs="0" maxOccurs="1"/>
</sequence>
</complexType>



<element name="beginTransaction">
-
<complexType>
-
<sequence>
<element name="duration" type="xsd:int" minOccurs="1" maxOccurs="1"/>
</sequence>
</complexType>
</element>


<!-- operation request element -->
-
<element name="commitTransaction">
-
<complexType>
-
<sequence>
<element name="transaction" type="condor:Transaction" minOccurs="1"
maxOccurs="1"/>
</sequence>
</complexType>
</element>
<!-- operation response element -->


==============================================


wsdl = 'http://133.24.112.97:63962/condorSchedd.wsdl'

drv = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver


p drv

res = drv.beginTransaction({'duration' => 20})




ignored attr: {}nillable
#<SOAP::RPC::Driver:#<SOAP::RPC::Proxy:http://localhost:80>>
/usr/local/lib/ruby/1.8/net/http.rb:560:in `initialize': Connection
refused - connect(2) (Errno::ECONNREFUSED)
        from /usr/local/lib/ruby/1.8/net/http.rb:560:in `open'
        from /usr/local/lib/ruby/1.8/net/http.rb:560:in `connect'
        from /usr/local/lib/ruby/1.8/timeout.rb:48:in `timeout'
        from /usr/local/lib/ruby/1.8/timeout.rb:76:in `timeout'
        from /usr/local/lib/ruby/1.8/net/http.rb:560:in `connect'
        from /usr/local/lib/ruby/1.8/net/http.rb:553:in `do_start'
        from /usr/local/lib/ruby/1.8/net/http.rb:542:in `start'
        from /usr/local/lib/ruby/1.8/soap/netHttpClient.rb:115:in
`start'
        from /usr/local/lib/ruby/1.8/soap/netHttpClient.rb:92:in
`post'
        from /usr/local/lib/ruby/1.8/soap/streamHandler.rb:170:in
`send_post'
        from /usr/local/lib/ruby/1.8/soap/streamHandler.rb:109:in
`send'
        from /usr/local/lib/ruby/1.8/soap/rpc/proxy.rb:170:in `route'
        from /usr/local/lib/ruby/1.8/soap/rpc/proxy.rb:141:in `call'
        from /usr/local/lib/ruby/1.8/soap/rpc/driver.rb:178:in `call'
        from /usr/local/lib/ruby/1.8/soap/rpc/driver.rb:232:in
`beginTransaction'
        from soap3.rb:11

If I do this, passing the parameter like this:


res = drv.beginTransaction(20)

I get:

#<SOAP::RPC::Driver:#<SOAP::RPC::Proxy:http://localhost:80>>
/usr/local/lib/ruby/1.8/soap/mapping/wsdlliteralregistry.rb:133:in
`complexobj2soap': nil not allowed: duration
(SOAP::Mapping::MappingError)
        from /usr/local/lib/ruby/1.8/wsdl/xmlSchema/complexType.rb:
56:in `each_element'
        from /usr/local/lib/ruby/1.8/wsdl/xmlSchema/complexType.rb:
52:in `each'
        from /usr/local/lib/ruby/1.8/wsdl/xmlSchema/complexType.rb:
52:in `each_element'
        from /usr/local/lib/ruby/1.8/soap/mapping/
wsdlliteralregistry.rb:122:in `complexobj2soap'
        from /usr/local/lib/ruby/1.8/soap/mapping/
wsdlliteralregistry.rb:108:in `obj2typesoap'
        from /usr/local/lib/ruby/1.8/soap/mapping/
wsdlliteralregistry.rb:93:in `obj2elesoap'
        from /usr/local/lib/ruby/1.8/soap/mapping/
wsdlliteralregistry.rb:39:in `obj2soap'
        from /usr/local/lib/ruby/1.8/soap/mapping/mapping.rb:127:in
`_obj2soap'
         ... 10 levels...
        from /usr/local/lib/ruby/1.8/soap/rpc/proxy.rb:123:in `call'
        from /usr/local/lib/ruby/1.8/soap/rpc/driver.rb:178:in `call'
        from /usr/local/lib/ruby/1.8/soap/rpc/driver.rb:232:in
`beginTransaction'
        from soap3.rb:12
This topic is locked and can not be replied to.