eegore
unread,Jun 17, 2008, 3:34:41 PM6/17/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to soap4r
I've been struggling with this problem for awhile now, it seems like
it should be really simple.
in the generated ruby code, I get the following 3 classes defined (in
addition to others that I believe are irrelevant to this problem)
class BodyType < ::Array
end
# xmlattr_key - SOAP::SOAPString
class ItemType
AttrKey = XSD::QName.new(nil, "key")
attr_reader :__xmlele_any
def set_any(elements)
@__xmlele_any = elements
end
def __xmlattr
@__xmlattr ||= {}
end
def xmlattr_key
__xmlattr[AttrKey]
end
def xmlattr_key=(value)
__xmlattr[AttrKey] = value
end
def initialize
@__xmlele_any = nil
@__xmlattr = {}
end
end
class VendorRequest
attr_accessor :identity
def __xmlattr
@__xmlattr ||= {}
end
def initialize(identity = nil)
@identity = identity
@__xmlattr = {}
end
end
# in addition, there are the following 3 calls to
LiteralRegistry.register
LiteralRegistry.register(
:class => BodyType,
:schema_type => XSD::QName.new(NsApi_0, "BodyType"),
:schema_element => [
["item", ["ItemType[]", XSD::QName.new(NsApi_0, "Item")]]
]
)
LiteralRegistry.register(
:class => ItemType,
:schema_type => XSD::QName.new(NsApi_0, "ItemType"),
:schema_element => [
["any", [nil, XSD::QName.new(NsXMLSchema, "anyType")]]
],
:schema_attribute => {
XSD::QName.new(nil, "key") => "SOAP::SOAPString"
}
)
LiteralRegistry.register(
:class => VendorRequest,
:schema_name => XSD::QName.new(NsRequest, "VendorRequest"),
:schema_element => [
["identity", ["Identity", XSD::QName.new(NsRequest,
"Identity")]]
],
)
I am trying to output xml that should look like:
<Body>
<Item key="someKey">
<VendorRequest>
<Identity> xml here </Identity>
</VendorRequest>
</Item>
</Body>
the code I am using to generate the output looks like this:
request = VendorRequest.new
#initialize the request with data here
body = BodyType.new
body[0] = ItemType.new
body[0].set_any([request])
when I do this I get the following error:
Message: <"malformed XML: missing tag start\nLine: \nPosition: \nLast
80 unconsumed characters:\n<#<VendorRequest:0x196fc34>></
#<VendorRequest:0x196fc34>>
it is trying to put the request in as a string.
It seems I either need to get the xml string the VendorRequest will
generate, or make some other call to the ItemType (but I've looked at
the public_methods, and can't see any way to do that).
if I use the following lines of code:
body = BodyType.new
body[0] = request
then I get the right XML, except that my <Item> tag is missing
altogether.
I'm sure I'm missing something simple here, but I can't find any kind
of decent documentation for soap4r to read...