The real world are taking some time from that but it is definitely on
the radar. Note that the post will not be a "How to do complex headers
using soap4r" but rather "How to call a SOAP service needing complex
headers without using soap4r". The use case is where you do not have
heavy SOAP interaction, for example one SOAP call to get external data.
More along the lines of a "what happens under the hood when calling a
SOAP service" to demystify the SOAP process a bit. I will post here once
the text is up.
/Erik
DanW skrev:
require 'soap/header/simplehandler'
n = XSD::NS.new
n.assign("soap", "")
class HeaderHandler < SOAP::Header::SimpleHandler
attr_accessor :value
def initialize(ns,tag)
super(XSD::QName.new(ns, tag))
@value = value
end
def on_simple_outbound
@value
end
End
h =
HeaderHandler.new("http://service.asurion.com/schemas/MessageHeader/1.0.0",
"MessageHeader")
driver.headerhandler << h
h.value = {XSD::QName.new("http://example.com/schemas/MessageHeader/1.0.0",
"Context") => {XSD::QName.new("http://example.com/schemas/
exampleCanonicalModel/1.0.0", "Culture") => "en-US" ,
XSD::QName.new("http://example.com/schemas/ exampleCanonicalModel/1.0.0",
"TimeStamp") => "2009-01-09T17:44:32.6441748Z", XSD::QName.new("http://
example.com/schemas/exampleCanonicalModel/1.0.0", "Principal") =>
{XSD::QName.new("http://example.com/schemas/exampleCanonicalModel/1.0.0","Sy
stemUsername") => "clientname",
XSD::QName.new("http://example.com/schemas/exampleCanonicalModel/1.0.0","Sys
temPassword") => 55555555},
XSD::QName.new("http://example.com/schemas/exampleCanonicalModel/1.0.0",
"LineOfBusiness") => "Handset",
XSD::QName.new("http://example.com/schemas/exampleCanonicalModel/1.0.0",
"Application") => "Aggregator",
XSD::QName.new("http://example.com/schemas/exampleCanonicalModel/1.0.0",
"Client") => "Google",
XSD::QName.new("http://example.com/schemas/exampleCanonicalModel/1.0.0",
"Channel") => "InStore"}}
###################################### Output of header from wiredump
<soap:Header>
<n1:MessageHeader
xmlns:n1="http://example.com/schemas/MessageHeader/1.0.0"
soap:mustUnderstand="0">
<n1:Context
xmlns:n2="http://example.com/schemas/exampleCanonicalModel/1.0.0">
<n2:LineOfBusiness>Handset</n2:LineOfBusiness>
<n2:Client>Google</n2:Client>
<n2:Channel>InStore</n2:Channel>
<n2:Application>Aggregator</n2:Application>
<n2:Principal>
<n2:SystemPassword>55555555</n2:SystemPassword>
<n2:SystemUsername>clientname</n2:SystemUsername>
</n2:Principal>
<n2:TimeStamp>2009-01-09T17:44:32.6441748Z</n2:TimeStamp>
<n2:Culture>en-US</n2:Culture>
</n1:Context>
</n1:MessageHeader>
</soap:Header>