📄 http.html
字号:
<p>Crypt::SSLeay (which is used for https support) will take care about
everything else. Other options (like CA peer verification) can be specified
in a similar way. See Crypt::SSLeay documentation for more details.</p>
<p>Those who would like to use encrypted keys may check
<a href="http://groups.yahoo.com/group/soaplite/message/729">http://groups.yahoo.com/group/soaplite/message/729</a> for details.</p>
<p>
</p>
<h2><a name="compression">COMPRESSION</a></h2>
<p>SOAP::Lite provides you with the option for enabling compression on the
wire (for HTTP transport only). Both server and client should support
this capability, but this should be absolutely transparent to your
application. The Server will respond with an encoded message only if
the client can accept it (indicated by client sending an Accept-Encoding
header with 'deflate' or '*' values) and client has fallback logic,
so if server doesn't understand specified encoding
(Content-Encoding: deflate) and returns proper error code
(415 NOT ACCEPTABLE) client will repeat the same request without encoding
and will store this server in a per-session cache, so all other requests
will go there without encoding.</p>
<p>Having options on client and server side that let you specify threshold
for compression you can safely enable this feature on both client and
server side.</p>
<dl>
<dt><strong>Client</strong>
<dd>
<pre>
<span class="keyword">print</span> <span class="variable">SOAP::Lite</span>
<span class="operator">-></span> <span class="variable">uri</span><span class="operator">(</span><span class="string">'http://localhost/My/Parameters'</span><span class="operator">)</span>
<span class="operator">-></span> <span class="variable">proxy</span><span class="operator">(</span><span class="string">'http://localhost/'</span><span class="operator">,</span> <span class="string">options</span> <span class="operator">=></span> <span class="operator">{</span><span class="string">compress_threshold</span> <span class="operator">=></span> <span class="number">10000</span><span class="operator">}</span><span class="operator">)</span>
<span class="operator">-></span> <span class="variable">echo</span><span class="operator">(</span><span class="number">1</span> <span class="operator">x</span> <span class="number">10000</span><span class="operator">)</span>
<span class="operator">-></span> <span class="variable">result</span>
<span class="operator">;</span>
</pre>
</dd>
<dt><strong><a name="item_server">Server</a></strong>
<dd>
<pre>
<span class="keyword">my</span> <span class="variable">$server</span> <span class="operator">=</span> <span class="variable">SOAP::Transport::HTTP::CGI</span>
<span class="operator">-></span> <span class="variable">dispatch_to</span><span class="operator">(</span><span class="string">'My::Parameters'</span><span class="operator">)</span>
<span class="operator">-></span> <span class="variable">options</span><span class="operator">(</span><span class="operator">{</span><span class="string">compress_threshold</span> <span class="operator">=></span> <span class="number">10000</span><span class="operator">}</span><span class="operator">)</span>
<span class="operator">-></span> <span class="variable">handle</span><span class="operator">;</span>
</pre>
</dd>
</dl>
<p>Compression will be enabled on the client side
<strong>if</strong> the threshold is specified
<strong>and</strong> the size of current message is bigger than the threshold
<strong>and</strong> the module Compress::Zlib is available.</p>
<p>The Client will send the header 'Accept-Encoding' with value 'deflate'
<strong>if</strong> the threshold is specified
<strong>and</strong> the module Compress::Zlib is available.</p>
<p>Server will accept the compressed message if the module Compress::Zlib
is available, and will respond with the compressed message
<strong>only if</strong> the threshold is specified
<strong>and</strong> the size of the current message is bigger than the threshold
<strong>and</strong> the module Compress::Zlib is available
<strong>and</strong> the header 'Accept-Encoding' is presented in the request.</p>
<p>
</p>
<hr />
<h1><a name="examples">EXAMPLES</a></h1>
<p>Consider following examples of SOAP servers:</p>
<dl>
<dt><strong><a name="item_cgi_3a">CGI:</a></strong>
<dd>
<pre>
<span class="keyword">use</span> <span class="variable">SOAP::Transport::HTTP</span><span class="operator">;</span>
</pre>
</dd>
<dd>
<pre>
<span class="variable">SOAP::Transport::HTTP::CGI</span>
<span class="operator">-></span> <span class="variable">dispatch_to</span><span class="operator">(</span><span class="string">'/Your/Path/To/Deployed/Modules'</span><span class="operator">,</span> <span class="string">'Module::Name'</span><span class="operator">,</span> <span class="string">'Module::method'</span><span class="operator">)</span>
<span class="operator">-></span> <span class="variable">handle</span>
<span class="operator">;</span>
</pre>
</dd>
<dt><strong><a name="item_daemon_3a">daemon:</a></strong>
<dd>
<pre>
<span class="keyword">use</span> <span class="variable">SOAP::Transport::HTTP</span><span class="operator">;</span>
</pre>
</dd>
<dd>
<pre>
<span class="keyword">my</span> <span class="variable">$daemon</span> <span class="operator">=</span> <span class="variable">SOAP::Transport::HTTP::Daemon</span>
<span class="operator">-></span> <span class="variable">new</span> <span class="operator">(</span><span class="string">LocalAddr</span> <span class="operator">=></span> <span class="string">'localhost'</span><span class="operator">,</span> <span class="string">LocalPort</span> <span class="operator">=></span> <span class="number">80</span><span class="operator">)</span>
<span class="operator">-></span> <span class="variable">dispatch_to</span><span class="operator">(</span><span class="string">'/Your/Path/To/Deployed/Modules'</span><span class="operator">,</span> <span class="string">'Module::Name'</span><span class="operator">,</span> <span class="string">'Module::method'</span><span class="operator">)</span>
<span class="operator">;</span>
<span class="keyword">print</span> <span class="string">"Contact to SOAP server at "</span><span class="operator">,</span> <span class="variable">$daemon</span><span class="operator">-></span><span class="variable">url</span><span class="operator">,</span> <span class="string">"\n"</span><span class="operator">;</span>
<span class="variable">$daemon</span><span class="operator">-></span><span class="variable">handle</span><span class="operator">;</span>
</pre>
</dd>
<dt><strong><a name="item_mod_perl_3a">mod_perl:</a></strong>
<dd>
<p>httpd.conf:</p>
</dd>
<dd>
<pre>
<Location /soap>
SetHandler perl-script
PerlHandler SOAP::Apache
</Location></pre>
</dd>
<dd>
<p>Apache.pm:</p>
</dd>
<dd>
<pre>
<span class="keyword">package</span> <span class="variable">SOAP::Apache</span><span class="operator">;</span>
</pre>
</dd>
<dd>
<pre>
<span class="keyword">use</span> <span class="variable">SOAP::Transport::HTTP</span><span class="operator">;</span>
</pre>
</dd>
<dd>
<pre>
<span class="keyword">my</span> <span class="variable">$server</span> <span class="operator">=</span> <span class="variable">SOAP::Transport::HTTP::Apache</span>
<span class="operator">-></span> <span class="variable">dispatch_to</span><span class="operator">(</span><span class="string">'/Your/Path/To/Deployed/Modules'</span><span class="operator">,</span> <span class="string">'Module::Name'</span><span class="operator">,</span> <span class="string">'Module::method'</span><span class="operator">);</span>
</pre>
</dd>
<dd>
<pre>
<span class="keyword">sub</span><span class="variable"> handler </span><span class="operator">{</span> <span class="variable">$server</span><span class="operator">-></span><span class="variable">handler</span><span class="operator">(</span><span class="variable">@_</span><span class="operator">)</span> <span class="operator">}</span>
</pre>
</dd>
<dd>
<pre>
<span class="number">1</span><span class="operator">;</span>
</pre>
</dd>
</li>
<dt><strong><a name="item_apache_3a_3aregistry_3a">Apache::Registry:</a></strong>
<dd>
<p>httpd.conf:</p>
</dd>
<dd>
<pre>
Alias /mod_perl/ "/Apache/mod_perl/"
<Location /mod_perl>
SetHandler perl-script
PerlHandler Apache::Registry
PerlSendHeader On
Options +ExecCGI
</Location></pre>
</dd>
<dd>
<p>soap.mod_cgi (put it in /Apache/mod_perl/ directory mentioned above)</p>
</dd>
<dd>
<pre>
<span class="keyword">use</span> <span class="variable">SOAP::Transport::HTTP</span><span class="operator">;</span>
</pre>
</dd>
<dd>
<pre>
<span class="variable">SOAP::Transport::HTTP::CGI</span>
<span class="operator">-></span> <span class="variable">dispatch_to</span><span class="operator">(</span><span class="string">'/Your/Path/To/Deployed/Modules'</span><span class="operator">,</span> <span class="string">'Module::Name'</span><span class="operator">,</span> <span class="string">'Module::method'</span><span class="operator">)</span>
<span class="operator">-></span> <span class="variable">handle</span>
<span class="operator">;</span>
</pre>
</dd>
</li>
</dl>
<p>WARNING: dynamic deployment with Apache::Registry will fail, because
module will be loaded dynamically only for the first time. After that
it is already in the memory, that will bypass dynamic deployment and
produces error about denied access. Specify both PATH/ and MODULE name
in <a href="#item_dispatch_to"><code>dispatch_to()</code></a> and module will be loaded dynamically and then will work
as under static deployment. See examples/server/soap.mod_cgi for example.</p>
<p>
</p>
<hr />
<h1><a name="troubleshooting">TROUBLESHOOTING</a></h1>
<dl>
<dt><strong><a name="item_dynamic_libraries_are_not_found">Dynamic libraries are not found</a></strong>
<dd>
<p>If you see in webserver's log file something like this:</p>
</dd>
<dd>
<p>Can't load '/usr/local/lib/perl5/site_perl/.../XML/Parser/Expat/Expat.so'
for module XML::Parser::Expat: dynamic linker: /usr/local/bin/perl:
libexpat.so.0 is NEEDED, but object does not exist at
/usr/local/lib/perl5/.../DynaLoader.pm line 200.</p>
</dd>
<dd>
<p>and you are using Apache web server, try to put into your httpd.conf</p>
</dd>
<dd>
<pre>
<IfModule mod_env.c>
PassEnv LD_LIBRARY_PATH
</IfModule></pre>
</dd>
</li>
<dt><strong><a name="item_segfaults">Apache is crashing with segfaults (it may looks like "500 unexpected EOF before status line seen" on client side)</a></strong>
<dd>
<p>If using SOAP::Lite (or XML::Parser::Expat) in combination with mod_perl
causes random segmentation faults in httpd processes try to configure
Apache with:</p>
</dd>
<dd>
<pre>
RULE_EXPAT=no</pre>
</dd>
<dd>
<p>-- OR (for Apache 1.3.20 and later) --</p>
</dd>
<dd>
<pre>
./configure --disable-rule=EXPAT</pre>
</dd>
<dd>
<p>See <a href="http://archive.covalent.net/modperl/2000/04/0185.xml">http://archive.covalent.net/modperl/2000/04/0185.xml</a> for more
details and lot of thanks to Robert Barta <<a href="mailto:rho@bigpond.net.au">rho@bigpond.net.au</a>> for
explaining this weird behavior.</p>
</dd>
<dd>
<p>If it doesn't help, you may also try -Uusemymalloc
(or something like that) to get perl to use the system's own malloc.
Thanks to Tim Bunce <<a href="mailto:Tim.Bunce@pobox.com">Tim.Bunce@pobox.com</a>>.</p>
</dd>
</li>
<dt><strong>CGI scripts are not running under Microsoft Internet Information Server (IIS)</strong>
<dd>
<p>CGI scripts may not work under IIS unless scripts are .pl, not .cgi.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="dependencies">DEPENDENCIES</a></h1>
<pre>
Crypt::SSLeay for HTTPS/SSL
SOAP::Lite, URI for SOAP::Transport::HTTP::Server
LWP::UserAgent, URI for SOAP::Transport::HTTP::Client
HTTP::Daemon for SOAP::Transport::HTTP::Daemon
Apache, Apache::Constants for SOAP::Transport::HTTP::Apache</pre>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<pre>
See ::CGI, ::Daemon and ::Apache for implementation details.
See examples/server/soap.cgi as SOAP::Transport::HTTP::CGI example.
See examples/server/soap.daemon as SOAP::Transport::HTTP::Daemon example.
See examples/My/Apache.pm as SOAP::Transport::HTTP::Apache example.</pre>
<p>
</p>
<hr />
<h1><a name="copyright">COPYRIGHT</a></h1>
<p>Copyright (C) 2000-2001 Paul Kulchenko. All rights reserved.</p>
<p>This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.</p>
<p>
</p>
<hr />
<h1><a name="author">AUTHOR</a></h1>
<p>Paul Kulchenko (<a href="mailto:paulclinger@yahoo.com">paulclinger@yahoo.com</a>)</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -