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

Ticket #331 (closed enhancement: fixed)

Opened 2 years ago

Last modified 1 year ago

attributes with namespaces

Reported by: nahi Assigned to: nahi
Priority: normal Milestone: 1.5.6
Component: soap4r Version: 1.5
Keywords: Cc:

Description

from soap4r-ml:

The SOAP service that i am trying to connect to uses attributes that
are in a specified namespace:

...
<env:Body>
  <gno:getHealthSummary xmlns:gno='http://some.url'>
    <gno:account gno:id='1234' />
  </gno:getHealthSummary>
</env:Body>
...

It is my understanding that soap4r does not support attributes with
namespaces, but i need to communicate with this service.  Short of
writing my own SOAP API is there anything I can do?  It appears to
work when i do this:

require 'soap/rpc/driver'

driver = SOAP::RPC::Driver.new('http://some.url/report.pl', 'http://
some.url')
driver.wiredump_dev = STDERR if true # $DEBUG

method = [ "http://some.url/getHealthSummary",
      "getHealthSummary",
      [ ["in", "parameters", ["::SOAP::SOAPElement", "http://
some.url", "getHealthSummary"], true],
        ["out", "parameters", ["::SOAP::SOAPElement", "http://
some.url", "getHealthSummaryResponse"], true] ],
      { :request_style =>  :document, :request_use =>  :literal,
        :response_style => :document, :response_use => :literal }
    ];

driver.add_document_operation(*method);

methodElement = SOAP::SOAPElement.new(XSD::QName.new("http://
some.url", "getHealthSummary"));
methodElement.extraattr['xmlns:gno'] = 'http://some.url';
account = SOAP::SOAPElement.new(XSD::QName.new("http://some.url",
"account"));
account.extraattr["gno:id"] = 1;
methodElement.add(account);

puts 'getHealthSummary';
results = driver.getHealthSummary(methodElement);
p results;

But it is a huge hack in that i have to put the namespace in as an
attribute on the containing element and give the id a pre-prefixed
name.

Change History

05/16/07 11:39:22 changed by nahi

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

05/16/07 21:46:18 changed by nahi

  • priority changed from high to normal.
  • type changed from defect to enhancement.
  • milestone changed from 1.5.6 to undefined.

06/10/07 10:27:05 changed by nahi

  • milestone changed from undefined to 1.5.7.

06/12/07 23:48:40 changed by nahi

  • milestone changed from 1.5.7 to 1.5.6.

I'll allow to set XML attribute with namespace:

{
  "elename1" => "elevalue1",
  "xmlattr_attrname1" => "attrvalue",  # "attrname1" is added as an XML attribute
  XSD::QName.new(ns, "elename2") => "elevalue2",
  XSD::QName.new(ns, "xmlattr_attrname2") => "attrvalue2"
}

06/12/07 23:55:55 changed by nahi

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

(In [1846]) * SOAPElement.from_obj(obj): allow to set XML attribute.

This method is called when you pass a Hash or [['key1', 'value1'], ...] to literal service so you can easily add XML attribute to a request.

when obj is a Hash or an Array:

when key starts with "xmlattr_":

value is added as an XML attribute with the key name however the "xmlattr_" is dropped from the name.

when key starts with "xmlele_":

value is added as an XML element with the key name however the "xmlele_" is dropped from the name.

if else:

value is added as an XML element with the key name.

closes #331.