[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

SOAP XML Generation from a SOAP Object (Soap4r 1.5.4

Dan Fitzpatrick

7/9/2005 8:39:00 AM

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/WhichAPI... 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... 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


1 Answer

NAKAMURA, Hiroshi

7/16/2005 1:02:00 PM

0

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

Hi,

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

Dan Fitzpatrick wrote:
> 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/WhichAPI... 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/WhichAPI...

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

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