1# ======================================================================
2#
3# Copyright (C) 2000-2004 Paul Kulchenko (paulclinger@yahoo.com)
4#
5# SOAP::Lite is free software; you can redistribute it
6# and/or modify it under the same terms as Perl itself.
7#
8# ======================================================================
9package SOAP::Constants;
10use strict;
11use SOAP::Lite;
12
13our $VERSION = 1.11;
14
15use constant    URI_1999_SCHEMA_XSD    => "http://www.w3.org/1999/XMLSchema";
16use constant    URI_1999_SCHEMA_XSI    => "http://www.w3.org/1999/XMLSchema-instance";
17use constant    URI_2000_SCHEMA_XSD    => "http://www.w3.org/2000/10/XMLSchema";
18use constant    URI_2000_SCHEMA_XSI    => "http://www.w3.org/2000/10/XMLSchema-instance";
19use constant    URI_2001_SCHEMA_XSD    => "http://www.w3.org/2001/XMLSchema";
20use constant    URI_2001_SCHEMA_XSI    => "http://www.w3.org/2001/XMLSchema-instance";
21use constant    URI_LITERAL_ENC        => "";
22use constant    URI_SOAP11_ENC         => "http://schemas.xmlsoap.org/soap/encoding/";
23use constant    URI_SOAP11_ENV         => "http://schemas.xmlsoap.org/soap/envelope/";
24use constant    URI_SOAP11_NEXT_ACTOR  => "http://schemas.xmlsoap.org/soap/actor/next";
25use constant    URI_SOAP12_ENC         => "http://www.w3.org/2003/05/soap-encoding";
26use constant    URI_SOAP12_ENV         => "http://www.w3.org/2003/05/soap-envelope";
27use constant    URI_SOAP12_NOENC       => "http://www.w3.org/2003/05/soap-envelope/encoding/none";
28use constant    URI_SOAP12_NEXT_ACTOR  => "http://www.w3.org/2003/05/soap-envelope/role/next";
29
30use vars qw($NSMASK $ELMASK);
31
32$NSMASK = '[a-zA-Z_:][\w.\-:]*';
33$ELMASK = '^(?![xX][mM][lL])[a-zA-Z_][\w.\-]*$';
34
35use vars qw($NEXT_ACTOR $NS_ENV $NS_ENC $NS_APS
36    $FAULT_CLIENT $FAULT_SERVER $FAULT_VERSION_MISMATCH
37    $HTTP_ON_FAULT_CODE $HTTP_ON_SUCCESS_CODE $FAULT_MUST_UNDERSTAND
38    $NS_XSI_ALL $NS_XSI_NILS %XML_SCHEMAS $DEFAULT_XML_SCHEMA
39    $DEFAULT_HTTP_CONTENT_TYPE
40    $SOAP_VERSION %SOAP_VERSIONS $WRONG_VERSION
41    $NS_SL_HEADER $NS_SL_PERLTYPE $PREFIX_ENV $PREFIX_ENC
42    $DO_NOT_USE_XML_PARSER $DO_NOT_CHECK_MUSTUNDERSTAND
43    $DO_NOT_USE_CHARSET $DO_NOT_PROCESS_XML_IN_MIME
44    $DO_NOT_USE_LWP_LENGTH_HACK $DO_NOT_CHECK_CONTENT_TYPE
45    $MAX_CONTENT_SIZE $PATCH_HTTP_KEEPALIVE $DEFAULT_PACKAGER
46    @SUPPORTED_ENCODING_STYLES $OBJS_BY_REF_KEEPALIVE
47    $DEFAULT_CACHE_TTL
48    %XML_SCHEMA_OF
49    $HAS_ENCODE
50);
51
52$FAULT_CLIENT           = 'Client';
53$FAULT_SERVER           = 'Server';
54$FAULT_VERSION_MISMATCH = 'VersionMismatch';
55$FAULT_MUST_UNDERSTAND  = 'MustUnderstand';
56
57$HTTP_ON_SUCCESS_CODE = 200; # OK
58$HTTP_ON_FAULT_CODE   = 500; # INTERNAL_SERVER_ERROR
59
60@SUPPORTED_ENCODING_STYLES = ( URI_LITERAL_ENC,URI_SOAP11_ENC,URI_SOAP12_ENC,URI_SOAP12_NOENC );
61
62$WRONG_VERSION = 'Wrong SOAP version specified.';
63
64$SOAP_VERSION = '1.1';
65%SOAP_VERSIONS = (
66    1.1 => {
67        NEXT_ACTOR                => URI_SOAP11_NEXT_ACTOR,
68        NS_ENV                    => URI_SOAP11_ENV,
69        NS_ENC                    => URI_SOAP11_ENC,
70        DEFAULT_XML_SCHEMA        => URI_2001_SCHEMA_XSD,
71        DEFAULT_HTTP_CONTENT_TYPE => 'text/xml',
72    },
73    1.2 => {
74        NEXT_ACTOR                => URI_SOAP12_NEXT_ACTOR,
75        NS_ENV                    => URI_SOAP12_ENV,
76        NS_ENC                    => URI_SOAP12_ENC,
77        DEFAULT_XML_SCHEMA        => URI_2001_SCHEMA_XSD,
78        DEFAULT_HTTP_CONTENT_TYPE => 'application/soap+xml',
79    },
80);
81
82# schema namespaces
83%XML_SCHEMAS = ( # The '()' is necessary to put constants in SCALAR form
84    URI_1999_SCHEMA_XSD() => 'SOAP::XMLSchema1999',
85    URI_2001_SCHEMA_XSD() => 'SOAP::XMLSchema2001',
86    URI_SOAP11_ENC()      => 'SOAP::XMLSchemaSOAP1_1',
87    URI_SOAP12_ENC()      => 'SOAP::XMLSchemaSOAP1_2',
88);
89
90# schema namespaces
91%XML_SCHEMA_OF = ( # The '()' is necessary to put constants in SCALAR form
92    URI_1999_SCHEMA_XSD() => 'XMLSchema1999',
93    URI_2001_SCHEMA_XSD() => 'XMLSchema2001',
94    URI_SOAP11_ENC()      => 'XMLSchemaSOAP1_1',
95    URI_SOAP12_ENC()      => 'XMLSchemaSOAP1_2',
96);
97
98
99$NS_XSI_ALL = join join('|', map {"$_-instance"} grep {/XMLSchema/} keys %XML_SCHEMAS), '(?:', ')';
100$NS_XSI_NILS = join join('|', map { my $class = $XML_SCHEMAS{$_} . '::Serializer'; "\{($_)-instance\}" . $class->nilValue
101                                } grep {/XMLSchema/} keys %XML_SCHEMAS),
102                  '(?:', ')';
103
104# ApacheSOAP namespaces
105$NS_APS = 'http://xml.apache.org/xml-soap';
106
107# SOAP::Lite namespace
108$NS_SL_HEADER   = 'http://namespaces.soaplite.com/header';
109$NS_SL_PERLTYPE = 'http://namespaces.soaplite.com/perl';
110
111# default prefixes
112$PREFIX_ENV = 'soap';
113$PREFIX_ENC = 'soapenc';
114
115# others
116$DO_NOT_USE_XML_PARSER = 0;
117$DO_NOT_CHECK_MUSTUNDERSTAND = 0;
118$DO_NOT_USE_CHARSET = 0;
119$DO_NOT_PROCESS_XML_IN_MIME = 0;
120$DO_NOT_USE_LWP_LENGTH_HACK = 0;
121$DO_NOT_CHECK_CONTENT_TYPE = 0;
122$PATCH_HTTP_KEEPALIVE = 1;
123$OBJS_BY_REF_KEEPALIVE = 600; # seconds
124
125# TODO - use default packager constant somewhere
126$DEFAULT_PACKAGER = "SOAP::Packager::MIME";
127$DEFAULT_CACHE_TTL = 0;
128
129$HAS_ENCODE = eval "require Encode; 1";
130
1311;
132
133__END__
134
135=pod
136
137=head1 NAME
138
139SOAP::Constants - SOAP::Lite provides several variables to allows programmers and users to modify the behavior of SOAP::Lite in specific ways.
140
141=head1 DESCRIPTION
142
143A number of "constant" values are provided by means of this namespace. The values aren't constants in the strictest sense; the purpose of the values detailed here is to allow the application to change them if it desires to alter the specific behavior governed.
144
145=head1 CONSTANTS
146
147=head2 $DO_NOT_USE_XML_PARSER
148
149The SOAP::Lite package attempts to locate and use the L<XML::Parser> package, falling back on an internal, pure-Perl parser in its absence. This package is a fast parser, based on the Expat parser developed by James Clark. If the application sets this value to 1, there will be no attempt to locate or use XML::Parser. There are several reasons you might choose to do this. If the package will never be made available, there is no reason to perform the test. Setting this parameter is less time-consuming than the test for the package would be. Also, the XML::Parser code links against the Expat libraries for the C language. In some environments, this could cause a problem when mixed with other applications that may be linked against a different version of the same libraries. This was once the case with certain combinations of Apache, mod_perl and XML::Parser.
150
151=head2 $DO_NOT_USE_CHARSET
152
153Unless this parameter is set to 1, outgoing Content-Type headers will include specification of the character set used in encoding the message itself. Not all endpoints (client or server) may be able to properly deal with that data on the content header, however. If dealing with an endpoint that expects to do a more literal examination of the header as whole (as opposed to fully parsing it), this parameter may prove useful.
154
155=head2 $DO_NOT_CHECK_CONTENT_TYPE
156
157The content-type itself for a SOAP message is rather clearly defined, and in most cases, an application would have no reason to disable the testing of that header. This having been said, the content-type for SOAP 1.2 is still only a recommended draft, and badly coded endpoints might send valid messages with invalid Content-Type headers. While the "right" thing to do would be to reject such messages, that isn't always an option. Setting this parameter to 1 allows the toolkit to skip the content-type test.
158
159=head2 $PATCH_HTTP_KEEPALIVE
160
161SOAP::Lite's HTTP Transport module attempts to provide a simple patch to
162LWP::Protocol to enable HTTP Keep Alive. By default, this patch is turned
163off, if however you would like to turn on the experimental patch change the
164constant like so:
165
166  $SOAP::Constants::PATCH_HTTP_KEEPALIVE = 1;
167
168=head1 ACKNOWLEDGEMENTS
169
170Special thanks to O'Reilly publishing which has graciously allowed SOAP::Lite to republish and redistribute large excerpts from I<Programming Web Services with Perl>, mainly the SOAP::Lite reference found in Appendix B.
171
172=head1 COPYRIGHT
173
174Copyright (C) 2000-2004 Paul Kulchenko. All rights reserved.
175
176This library is free software; you can redistribute it and/or modify
177it under the same terms as Perl itself.
178
179=head1 AUTHORS
180
181Paul Kulchenko (paulclinger@yahoo.com)
182
183Randy J. Ray (rjray@blackperl.com)
184
185Byrne Reese (byrne@majordojo.com)
186
187=cut
188