| | 10 | |
|---|
| | 11 | class MappablePerson |
|---|
| | 12 | attr_reader :name |
|---|
| | 13 | attr_reader :age |
|---|
| | 14 | |
|---|
| | 15 | def initialize(name, age) |
|---|
| | 16 | @name, @age = name, age |
|---|
| | 17 | end |
|---|
| | 18 | |
|---|
| | 19 | def self.soap_marshallable |
|---|
| | 20 | true |
|---|
| | 21 | end |
|---|
| | 22 | end |
|---|
| | 23 | |
|---|
| | 24 | class UnmappablePerson |
|---|
| | 25 | attr_reader :name |
|---|
| | 26 | attr_reader :age |
|---|
| | 27 | |
|---|
| | 28 | def initialize(name, age) |
|---|
| | 29 | @name, @age = name, age |
|---|
| | 30 | end |
|---|
| | 31 | |
|---|
| | 32 | def self.soap_marshallable |
|---|
| | 33 | false |
|---|
| | 34 | end |
|---|
| | 35 | end |
|---|
| | 36 | |
|---|
| | 37 | def test_mappable |
|---|
| | 38 | xml = <<__XML__ |
|---|
| | 39 | <?xml version="1.0" encoding="utf-8" ?> |
|---|
| | 40 | <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" |
|---|
| | 41 | xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" |
|---|
| | 42 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|---|
| | 43 | <env:Body> |
|---|
| | 44 | <SOAP..TestMapping..MappablePerson env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> |
|---|
| | 45 | <name>nahi</name> |
|---|
| | 46 | <age>37</age> |
|---|
| | 47 | </SOAP..TestMapping..MappablePerson> |
|---|
| | 48 | </env:Body> |
|---|
| | 49 | </env:Envelope> |
|---|
| | 50 | __XML__ |
|---|
| | 51 | obj = SOAP::Marshal.load(xml) |
|---|
| | 52 | assert_equal(SOAP::TestMapping::MappablePerson, obj.class) |
|---|
| | 53 | # |
|---|
| | 54 | xml = <<__XML__ |
|---|
| | 55 | <?xml version="1.0" encoding="utf-8" ?> |
|---|
| | 56 | <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" |
|---|
| | 57 | xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" |
|---|
| | 58 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|---|
| | 59 | <env:Body> |
|---|
| | 60 | <SOAP..TestMapping..UnmappablePerson env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> |
|---|
| | 61 | <name>nahi</name> |
|---|
| | 62 | <age>37</age> |
|---|
| | 63 | </SOAP..TestMapping..UnmappablePerson> |
|---|
| | 64 | </env:Body> |
|---|
| | 65 | </env:Envelope> |
|---|
| | 66 | __XML__ |
|---|
| | 67 | obj = SOAP::Marshal.load(xml) |
|---|
| | 68 | assert_equal(SOAP::Mapping::Object, obj.class) |
|---|
| | 69 | end |
|---|
| | 70 | |
|---|