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

root/tags/RELEASE_1_0_0/lib/SOAPProcessor.rb

Revision 2, 1.8 kB (checked in by nakahiro, 8 years ago)

SOAP4R initial release.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to author date id revision
Line 
1 =begin
2 SOAP4R
3 Copyright (C) 2000 NAKAMURA Hiroshi.
4
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free Software
7 Foundation; either version 2 of the License, or (at your option) any later
8 version.
9
10 This program is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 PRATICULAR PURPOSE. See the GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along with
15 this program; if not, write to the Free Software Foundation, Inc., 675 Mass
16 Ave, Cambridge, MA 02139, USA.
17 =end
18
19 require 'SOAP'
20 require 'SOAPElement'
21 require 'XMLSchemaDatatypes'
22
23 module SOAPProcessor
24   public
25
26   ###
27   ## SOAP marshaling
28   #
29   def marshal( ns, header, body )
30
31     # Namespace preloading.
32     ns.assign( SOAP::EnvelopeNamespace, SOAPNamespaceTag )
33     ns.assign( XSD::Namespace, XSDNamespaceTag )
34     ns.assign( XSD::InstanceNamespace, XSINamespaceTag )
35
36     # Create SOAP envelope.
37     env = SOAPEnvelope.new( header, body )
38
39     # XML tree construction.
40     XML::SimpleTree::Document.new( env.encode( ns ))
41   end
42
43   ###
44   ## SOAP unmarshaling
45   #
46   def unmarshal( method, stream )
47
48     # Namespace preloading.
49     ns = SOAPNS.new()
50     ns.assign( SOAP::EnvelopeNamespace, SOAPNamespaceTag )
51     ns.assign( XSD::Namespace, XSDNamespaceTag )
52
53     # XML tree parsing.
54     builder = XML::SimpleTreeBuilder.new()
55     tree = builder.parse( stream )
56     tree.documentElement.normalize
57
58     # Parse SOAP envelope.
59     env = SOAPEnvelope.decode( ns, tree, method )
60
61     return ns, env.header, env.body
62   end
63
64   private
65
66   SOAPNamespaceTag = 'SOAP-ENV'
67   XSDNamespaceTag = 'xsd'
68   XSINamespaceTag = 'xsi'
69 end
Note: See TracBrowser for help on using the browser.