SOAP XML Generation from a SOAP Object (Soap4r 1.5.4)

  • Thread starter Dan Fitzpatrick
  • Start date
D

Dan Fitzpatrick

I am trying to create a soap xml string but am having only partial
success. Marshall.marshall works great but creating the XML string from
a SOAP object is not working for me.

Example A at http://dev.ctor.org/soap4r/wiki/WhichAPIshouldIuse is what
I would like to do. However there are multiple errors. Any assistance in
getting this example to work, or something similar is appreciated.

require 'soap/processor'

headerItem = SOAP::SOAPHeaderItem.new(
SOAP::SOAPElement.new( 'urn:ns', 'headerItem', 'text1' )
# The 3rd element is no longer valid for #new
)
header = SOAP::SOAPHeader.new
header.add( headerItem )
# 2 arguments are required for #add
bodyItem = SOAP::SOAPStruct.new( 'MyCustomClass' )
bodyItem.name = 'anObject'
# No longer a #name method in SOAP::SOAPStruct
bodyItem.add( 'str', SOAP::SOAPString.new( 'SOAP4R' ))
bodyItem.add( 'int', SOAP::SOAPInt.new( 1234 ))
bodyItem.add( 'dateTime', SOAP::SOAPDateTime.new( DateTime.now ))
body = SOAP::SOAPBody.new( bodyItem )
str = SOAP::processor.marshal( header, body )
# Returns the following error:
# XSD::NS::FormatError: namespace:
# http://schemas.xmlsoap.org/soap/envelope/ not defined yet
# from /usr/local/lib/ruby/1.8/xsd/ns.rb:77:in `name'
# from /usr/local/lib/ruby/1.8/soap/element.rb:189:in `encode'
# from /usr/local/lib/ruby/1.8/soap/generator.rb:127:in `encode_element'
# from /usr/local/lib/ruby/1.8/soap/generator.rb:65:in `encode_data'
# from /usr/local/lib/ruby/1.8/soap/generator.rb:53:in `generate'
# from /usr/local/lib/ruby/1.8/soap/processor.rb:30:in `marshal'

puts str
 
N

NAKAMURA, Hiroshi

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

This is a duplicate response of a mail in soap4r ML.

Dan said:
I am trying to create a soap xml string but am having only partial
success. Marshall.marshall works great but creating the XML string from
a SOAP object is not working for me.

Example A at http://dev.ctor.org/soap4r/wiki/WhichAPIshouldIuse is what
I would like to do. However there are multiple errors. Any assistance in
getting this example to work, or something similar is appreciated.

Sorry for the old examples. I updated the page. Please check the page
again.
http://dev.ctor.org/soap4r/wiki/WhichAPIshouldIuse

Regards,
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)

iD8DBQFC2QUSf6b33ts2dPkRAooRAJ4lAwFUoXJValkKHGSdS/5Hb7t1CQCgr2Pq
54DTHeN7As66SrXFOieLMs0=
=PfL+
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top