Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Ticket #450 (closed defect: invalid)

Opened 3 years ago

Last modified 2 years ago

Dropping attributes in soap request to xsd2ruby generated class

Reported by: user Assigned to: nahi
Priority: high Milestone: 1.5.9
Component: soap4r Version: 1.5
Keywords: Cc:

Description

Generate ruby class from xsd2ruby.rb xsd required attr below shows up as xattr_attr in class definition send xml doc <ele attr=xxx></ele> in soap request attr is "lost" in translation, i.e.: document.xattr_attr always returns nil

also unbounded arrays only include first element - all others "lost"

ruby 1.8.6, rails 1.2.5, soap4r 1.5.8, mac osx Leopard (10.5)

Attachments

Project.xsd (5.8 kB) - added by user on 11/07/07 00:56:33.
project.xml (26.9 kB) - added by user on 11/07/07 00:57:14.
soap4r.log (36.5 kB) - added by user on 11/07/07 00:58:38.

Change History

11/07/07 00:56:33 changed by user

  • attachment Project.xsd added.

11/07/07 00:57:14 changed by user

  • attachment project.xml added.

11/07/07 00:58:38 changed by user

  • attachment soap4r.log added.

11/07/07 22:55:48 changed by user

I changed mapping/rubytypeFactory.rb, and this fixed the attribute issue. Might not be the right place to do this...

  def soap2obj(obj_class, node, info, map)
#p "smrtf: s2o entry", obj_class, node, info, map
    rubytype = node.extraattr[RubyTypeName]
    obj = nil
    if rubytype or node.type.namespace == RubyTypeNamespace
      obj = rubytype2obj(node, info, map, rubytype)
    elsif node.type == XSD::AnyTypeName or node.type == XSD::AnySimpleTypeName
      obj = anytype2obj(node, info, map)
    else
      obj = unknowntype2obj(node, info, map)
    end

# AEB
#p "smrtf: s2o node", node.extraattr, obj
      node.extraattr.each do |key, value|
        obj[1].__xmlattr[key] = value
      end

#p "smrtf: s2o exit", obj
    obj
  end

12/22/07 09:17:49 changed by user

I'm having the same problem with the same versions. And, the hack above didn't do the trick either.

None of my attributes make it through XSD::Mapping.obj2xml.

01/27/08 07:35:30 changed by user

+1 I've also had this problem.

The suggested fix for soap2obj listed above did not work for me either. This is reproducible on Mac and Windows.

12/22/08 14:29:12 changed by nahi

  • priority changed from normal to high.
  • milestone changed from undefined to 1.5.9.

01/09/09 18:30:45 changed by nahi

  • status changed from new to closed.
  • resolution set to invalid.

According to soap4r.log, you are using xsd2ruby.rb for soap request. Please use wsdl2ruby.rb for that purpose.

xsd2ruby.rb is for XML <-> obj conversion, not for SOAP.

0% xsd2ruby.rb --xsd ../Project.xsd --classdef --mapping_registry --mapper
I, [2009-01-09T18:24:03.648150 #10132]  INFO -- app: Creating class definition.
I, [2009-01-09T18:24:03.648797 #10132]  INFO -- app: Creates file 'default.rb'.
I, [2009-01-09T18:24:03.706637 #10132]  INFO -- app: Creating mapping registry definition.
I, [2009-01-09T18:24:03.707143 #10132]  INFO -- app: Creates file 'default_mapping_registry.rb'.
unresolved attribute type  for {}id
unresolved attribute type  for {}name
unresolved attribute type  for {}finish
unresolved attribute type  for {}id
unresolved attribute type  for {}name
unresolved attribute type  for {}start
unresolved attribute type  for {}authorName
unresolved attribute type  for {}resourceRef
unresolved attribute type  for {}timestamp
unresolved attribute type  for {}id
unresolved attribute type  for {}title
unresolved attribute type  for {}id
unresolved attribute type  for {}name
unresolved attribute type  for {}url
I, [2009-01-09T18:24:03.734690 #10132]  INFO -- app: Creating mapper definition.
I, [2009-01-09T18:24:03.735043 #10132]  INFO -- app: Creates file 'default_mapper.rb'.
I, [2009-01-09T18:24:03.735870 #10132]  INFO -- app: End of app. (status: 0)

0% cat clnt.rb
require 'default_mapper'
mapper = DefaultMapper.new
doc = ProjectXWebAppDocument.new
prj = doc.project = Project.new
prj.xmlattr_id = 'id'
task = prj.task = Task.new
task.xmlattr_finish = 'finish'
puts mapper.obj2xml(doc)

0% ruby clnt.rb
<?xml version="1.0" encoding="utf-8" ?>
<ProjectXWebAppDocument>
  <Project id="id">
    <Task finish="finish">
      ...