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:rocessor.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
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:rocessor.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