I posted this to the soap mailing list but have not received any input.
Hopefully someone here knows the answer.
I am wondering how to change the namespace (xmlns) on the SetResponse
element from “http://www.ruby-lang.org/xmlns/ruby/type/custom” to a
different namespace using soap4r.
The following code produces the soap message below.
require ‘soap/mapping’
require ‘soap/processor’
class SetResult
attr_accessor :timestamp
attr_accessor :errorCode
attr_accessor :message
attr_accessor :id
attr_accessor :version
end
class SetResponse
attr_accessor :SetResult
end
response_object = SetResponse.new
result = SetResult.new
result.id = 1
result.version = 2
result.errorCode = 0
result.message = ‘Update Successful’
result.timestamp = Time.new.strftime(‘%Y-%m-%dT%H:%M:%S’)
response_object.SetResult = result
soap_header = SOAP::SOAPHeader.new
elename = SOAP::Mapping.name2elename(‘SetResponse’)
mapping_registry = SOAP::Mapping::Registry.new(:allow_original_mapping
=> false)
soap_obj = SOAP::Mapping.obj2soap(response_object, mapping_registry)
body = SOAP::SOAPBody.new
body.add(elename, soap_obj)
soap = SOAP::SOAPEnvelope.new(soap_header, body)
puts SOAP::Processor.marshal(soap, {}, nil)
Returns:
<?xml version="1.0" encoding="us-ascii" ?><env:Envelope xmlns:xsd=“XML Schema”
xmlns:env=“http://schemas.xmlsoap.org/soap/envelope/”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>
env:Body
2006-03-09T02:25:56
1
2
Update Successful
0
</env:Body>
</env:Envelope>
I need to change:
<SetResponse
xmlns:n1=“http://www.ruby-lang.org/xmlns/ruby/type/custom” …
to for example:
<SetResponse xmlns=“http://example.com/company” …
I also do not need the xsi:type in the soap message either. How do you
hide those attributes?
Thanks,
Dan