Commit 0070de20 authored by salaun's avatar salaun
Browse files

Changes: SOAP-related.


git-svn-id: https://subversion.renater.fr/sympa/trunk@2056 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 4bd2fc43
......@@ -8,6 +8,56 @@ use SOAP::Transport::HTTP;
1;
sub request {
my $self = shift;
if (my $request = $_[0]) {
my %sympa_cookies;
my @cookies = $request->headers->header('cookie');
foreach my $cookie ( @cookies) {
foreach my $token (split /;/,$cookie) {
$token =~ s/^\s+//;
$token =~ s/\s+$//;
my ($key, $value) = split(/=/,$token);
$value =~ s/^\"(.+)\"$/$1/;
if ($key =~ /^sympa/) {
$sympa_cookies{$key} = $value;
}
}
}
delete $ENV{'USER_EMAIL'};
if (defined $sympa_cookies{'sympauser'}) {
my ($email, $md5) = split /:/,$sympa_cookies{'sympauser'};
if (&cookielib::get_mac($email, $Conf::Conf{'cookie'}) eq $md5) {
$ENV{'USER_EMAIL'} = $email;
}
}
}
$self->SUPER::request(@_);
}
sub response {
my $self = shift;
if (my $response = $_[0]) {
if (defined $ENV{'USER_EMAIL'}) {
my $expire = $main::param->{'user'}{'cookie_delay'} || $main::wwsconf->{'cookie_expire'};
&cookielib::set_cookie_soap($ENV{'USER_EMAIL'}, $Conf::Conf{'cookie'}, $ENV{'SERVER_NAME'}, $expire);
}
if (defined $ENV{'SOAP_COOKIE_sympauser'}) {
$response->headers->push_header('Set-Cookie2' => $ENV{'SOAP_COOKIE_sympauser'});
delete $ENV{'SOAP_COOKIE_sympauser'};
}
}
$self->SUPER::request(@_);
}
## Redefine FCGI's handle subroutine
sub handle ($$) {
my $self = shift->new;
......@@ -19,11 +69,13 @@ sub handle ($$) {
## If fastcgi changed on disk, die
## Apache will restart the process
while (($r1 = $fcgirq->Accept()) >= 0) {
$r2 = $self->SOAP::Transport::HTTP::CGI::handle;
if ((stat($ENV{'SCRIPT_FILENAME'}))[9] > $birthday ) {
exit(0);
}
#print "Set-Cookie: sympa_altemails=olivier.salaun%40cru.fr; path=/; expires=Tue , 19-Oct-2004 14 :08:19 GMT\n";
}
return undef;
}
......@@ -70,12 +70,10 @@
<!-- message part -->
<message name="do_whichRequest">
<part name="email" type="xsd:string"/>
<part name="password" type="xsd:string"/>
<message name="whichRequest">
</message>
<message name="do_whichResponse">
<message name="whichResponse">
<part name="return" type="xsdl:ArrayOfLists"/>
</message>
......@@ -101,9 +99,6 @@
<message name="reviewRequest">
<part name="list" type="xsd:string"/>
<part name="robot" type="xsd:string"/>
<part name="sender" type="xsd:string"/>
<part name="password" type="xsd:string"/>
</message>
<message name="reviewResponse">
......@@ -112,51 +107,41 @@
<message name="signoffRequest">
<part name="list" type="xsd:string"/>
<part name="robot" type="xsd:string"/>
<part name="sender" type="xsd:string"/>
<part name="password" type="xsd:string"/>
<part name="email" type="xsd:string" minOccurs="0"/>
<part name="email" type="xsd:string" xsd:minOccurs="0"/>
</message>
<message name="signoffResponse">
<part name="return" type="xsdl:boolean"/>
<part name="return" type="xsd:boolean"/>
</message>
<message name="subscribeRequest">
<part name="list" type="xsd:string"/>
<part name="robot" type="xsd:string"/>
<part name="sender" type="xsd:string"/>
<part name="password" type="xsd:string"/>
<part name="gecos" type="xsd:string" minOccurs="0"/>
<part name="gecos" type="xsd:string" xsd:minOccurs="0"/>
</message>
<message name="subscribeResponse">
<part name="return" type="xsdl:boolean"/>
<part name="return" type="xsd:boolean"/>
</message>
<message name="do_loginRequest">
<message name="loginRequest">
<part name="email" type="xsd:string"/>
<part name="password" type="xsd:string"/>
</message>
<message name="do_loginResponse">
<part name="return" type="xsd:string"/>
<message name="loginResponse">
<part name="return" type="xsd:boolean"/>
</message>
<message name="do_listsRequest">
<part name="robot" type="xsd:string"/>
<part name="email" type="xsd:string"/>
<part name="password" type="xsd:string"/>
<part name="topic" type="xsd:string"/>
<message name="listsRequest">
<part name="topic" type="xsd:string" xsd:minOccurs="0"/>
<part name="subtopic" type="xsd:string"/>
</message>
<message name="do_listsResponse">
<message name="listsResponse">
<part name="return" type="xsdl:ArrayOfLists"/>
</message>
<message name="check_cookieRequest">
<part name="cookie" type="xsd:string"/>
</message>
<message name="check_cookieResponse">
......@@ -166,63 +151,39 @@
<!-- portType part -->
<portType name="do_whichPortType">
<operation name="do_which">
<input message="tns:do_whichRequest" />
<output message="tns:do_whichResponse" />
<portType name="SympaPort">
<operation name="which">
<input message="tns:whichRequest" />
<output message="tns:whichResponse" />
</operation>
</portType>
<portType name="isSubscriberPortType">
<operation name="isSubscriber">
<input message="tns:isSubscriberRequest" />
<output message="tns:isSubscriberResponse" />
</operation>
</portType>
<portType name="amIPortType">
<operation name="amI">
<input message="tns:amIRequest" />
<output message="tns:amIResponse" />
</operation>
</portType>
<portType name="reviewPortType">
<operation name="review">
<input message="tns:reviewRequest" />
<output message="tns:reviewResponse" />
</operation>
</portType>
<portType name="subscribePortType">
<operation name="subscribe">
<input message="tns:subscribeRequest" />
<output message="tns:subscribeResponse" />
</operation>
</portType>
<portType name="signoffPortType">
<operation name="signoff">
<input message="tns:signoffRequest" />
<output message="tns:signoffResponse" />
</operation>
</portType>
<portType name="do_loginPortType">
<operation name="do_login">
<input message="tns:do_loginRequest" />
<output message="tns:do_loginResponse" />
<operation name="login">
<input message="tns:loginRequest" />
<output message="tns:loginResponse" />
</operation>
</portType>
<portType name="do_listsPortType">
<operation name="do_lists">
<input message="tns:do_listsRequest" />
<output message="tns:do_listsResponse" />
<operation name="lists">
<input message="tns:listsRequest" />
<output message="tns:listsResponse" />
</operation>
</portType>
<portType name="check_cookiePortType">
<operation name="check_cookie">
<input message="tns:check_cookieRequest" />
<output message="tns:check_cookieResponse" />
......@@ -232,154 +193,122 @@
<!-- Binding part -->
<binding name="do_whichBinding" type="tns:do_whichPortType">
<binding name="SOAP" type="tns:SympaPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="do_which">
<soap:operation soapAction=""/>
<operation name="which">
<soap:operation soapAction="urn:sympasoap"/>
<input>
<soap:body use="encoded"
namespace="urn:do_which"
namespace="urn:sympasoap"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
namespace="urn:do_which"
namespace="urn:sympasoap"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<binding name="isSubscriberBinding" type="tns:isSubscriberPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="isSubscriber">
<soap:operation soapAction=""/>
<soap:operation soapAction="urn:sympasoap"/>
<input>
<soap:body use="encoded"
namespace="urn:isSubscriber"
namespace="urn:sympasoap"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
namespace="urn:isSubscriber"
namespace="urn:sympasoap"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<binding name="amIBinding" type="tns:amIPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="amI">
<soap:operation soapAction=""/>
<soap:operation soapAction="urn:sympasoap"/>
<input>
<soap:body use="encoded"
namespace="urn:amI"
namespace="urn:sympasoap"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
namespace="urn:amI"
namespace="urn:sympasoap"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<binding name="reviewBinding" type="tns:reviewPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="review">
<soap:operation soapAction=""/>
<soap:operation soapAction="urn:sympasoap"/>
<input>
<soap:body use="encoded"
namespace="urn:review"
namespace="urn:sympasoap"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
namespace="urn:review"
namespace="urn:sympasoap"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<binding name="subscribeBinding" type="tns:subscribePortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="subscribe">
<soap:operation soapAction=""/>
<soap:operation soapAction="urn:sympasoap"/>
<input>
<soap:body use="encoded"
namespace="urn:subscribe"
namespace="urn:sympasoap"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
namespace="urn:subscribe"
namespace="urn:sympasoap"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<binding name="signoffBinding" type="tns:signoffPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="signoff">
<soap:operation soapAction=""/>
<soap:operation soapAction="urn:sympasoap"/>
<input>
<soap:body use="encoded"
namespace="urn:signoff"
namespace="urn:sympasoap"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
namespace="urn:signoff"
namespace="urn:sympasoap"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<binding name="do_loginBinding" type="tns:do_loginPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="do_login">
<soap:operation soapAction=""/>
<operation name="login">
<soap:operation soapAction="urn:sympasoap"/>
<input>
<soap:body use="encoded"
namespace="urn:do_login"
namespace="urn:sympasoap"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
namespace="urn:do_login"
namespace="urn:sympasoap"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<binding name="do_listsBinding" type="tns:do_listsPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="do_lists">
<soap:operation soapAction=""/>
<operation name="lists">
<soap:operation soapAction="urn:sympasoap"/>
<input>
<soap:body use="encoded"
namespace="urn:do_lists"
namespace="urn:sympasoap"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
namespace="urn:do_lists"
namespace="urn:sympasoap"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<binding name="check_cookieBinding" type="tns:check_cookiePortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="check_cookie">
<soap:operation soapAction=""/>
<soap:operation soapAction="urn:sympasoap"/>
<input>
<soap:body use="encoded"
namespace="urn:check_cookie"
namespace="urn:sympasoap"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded"
namespace="urn:check_cookie"
namespace="urn:sympasoap"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
......@@ -389,59 +318,8 @@
<service name="SympaSOAP">
<documentation>
Sympa do_which SOAP Service.
</documentation>
<port name="do_whichPort" binding="tns:do_whichBinding">
<soap:address location="[conf->soap_url]/do_which"/>
</port>
<documentation>
Sympa isSubscriber SOAP Service.
</documentation>
<port name="isSubscriberPort" binding="tns:isSubscriberBinding">
<soap:address location="[conf->soap_url]/isSubscriber"/>
</port>
<documentation>
Sympa amI SOAP Service.
</documentation>
<port name="amIPort" binding="tns:amIBinding">
<soap:address location="[conf->soap_url]/amI"/>
</port>
<documentation>
Sympa review SOAP Service.
</documentation>
<port name="reviewPort" binding="tns:reviewBinding">
<soap:address location="[conf->soap_url]/review"/>
</port>
<documentation>
Sympa subscribe SOAP Service.
</documentation>
<port name="subscribePort" binding="tns:subscribeBinding">
<soap:address location="[conf->soap_url]/subscribe"/>
</port>
<documentation>
Sympa sign off SOAP Service.
</documentation>
<port name="signoffPort" binding="tns:signoffBinding">
<soap:address location="[conf->soap_url]/signoff"/>
</port>
<documentation>
Sympa login SOAP Service.
</documentation>
<port name="do_loginPort" binding="tns:do_loginBinding">
<soap:address location="[conf->soap_url]/do_login"/>
</port>
<documentation>
Sympa do_lists SOAP Service.
</documentation>
<port name="do_listsPort" binding="tns:do_listsBinding">
<soap:address location="[conf->soap_url]/do_lists"/>
</port>
<documentation>
Sympa check cookie SOAP Service.
</documentation>
<port name="check_cookiePort" binding="tns:check_cookieBinding">
<soap:address location="[conf->soap_url]/check_cookie"/>
<port name="SympaPort" binding="tns:SOAP">
<soap:address location="[conf->soap_url]"/>
</port>
</service>
......
......@@ -16,63 +16,92 @@
#use SOAP::Lite +trace;
use SOAP::Lite;
use HTTP::Cookies;
use URI;
use lib '--LIBDIR--';
use Conf;
require 'tools.pl';
#use Log;
use strict;
my $sympa_conf_file = '--CONFIG--';
my ($service, $reponse, @ret, $val, %fault);
## Load sympa config
#unless (&Conf::load($sympa_conf_file)) {
# printf STDERR 'Unable to load sympa config file %s', $sympa_conf_file;
#}
## Cookies management
my $uri = new URI('http://www.cru.fr/wwsoap');
my ($service, $reponse, @ret, $val, %fault);
my $cookies = HTTP::Cookies->new(ignore_discard => 1,
file => '/tmp/my_cookies' );
$cookies->load();
printf "%s\n", $cookies->as_string();
#$cookies->set_cookie(0, 'Y_Y_Y_Y' => 'X_X_X_X', '/', 'www.cru.fr');
# Change to the path of Sympa.wsdl
$service = SOAP::Lite->service('http://www.cru.fr/wws/wsdl');
#$service = SOAP::Lite->service('http://www.cru.fr/wws/wsdl');
#$reponse = $service->login($ARGV[0],$ARGV[1]);
my $soap = new SOAP::Lite();
$soap->uri('urn:sympasoap');
$soap->proxy('http://www.cru.fr/wwsoap',
cookie_jar =>$cookies);
# ->outputxml(1);
# ->readable(1);
# Select your function
#$reponse = $service->amI($ARGV[0],$ARGV[1],$ARGV[2]);
#$reponse = $service->isSubscriber($ARGV[0],$ARGV[1]);
#$reponse = $service->review($ARGV[0],$ARGV[1],$ARGV[2],$ARGV[3],$ARGV[4]);
#$reponse = $service->subscribe($ARGV[0],$ARGV[1],$ARGV[2],$ARGV[3],$ARGV[4]);
#$reponse = $service->sign_off($ARGV[0],$ARGV[1],$ARGV[2],$ARGV[3],$ARGV[4]);
#$reponse = $service->do_login($ARGV[0],$ARGV[1],$ARGV[2]);
#$reponse = $service->do_lists($ARGV[0],$ARGV[1],$ARGV[2],$ARGV[3],$ARGV[4]);
#$reponse = $service->which($ARGV[0],$ARGV[1]);
#$reponse = $service->do_which($ARGV[0],$ARGV[1]);
$reponse = $service->do_login($ARGV[0],$ARGV[1]);
print "LOGIN....\n";
$reponse = $soap->login($ARGV[0],$ARGV[1]);
$cookies->save;
&print_result($reponse);
# If we get a fault
if ($service->call->fault)
{
print "Soap error :\n";
%fault = %{$service->call->fault};
foreach $val (keys %fault)
{
print "$val = $fault{$val}\n";
}
}
else
{
if (ref( $service->call->result)) {
@ret = @{$service->call->result};
}else{
@ret = $service->call->result;
}
&tools::dump_var(\@ret, 0, \*STDOUT);
#printf "%s\n", $cookies->as_string();
print "\n\nWHICH....\n";
$reponse = $soap->which();
&print_result($reponse);
print "\n\nSUB....\n";
$reponse = $soap->subscribe('aliba', 'ALI');
&print_result($reponse);
print "\n\nREVIEW....\n";
$reponse = $soap->review('aliba');
&print_result($reponse);
}
print "\n\nSIG....\n";
$reponse = $soap->signoff('aliba');
&print_result($reponse);
print "\n\nLIST....\n";
$reponse = $soap->lists('actualite');
&print_result($reponse);
print "\n\nCheck_cookie....\n";
$reponse = $soap->check_cookie();
&print_result($reponse);
sub print_result {
my $r = shift;
# If we get a fault
if ($r->fault) {
print "Soap error :\n";
%fault = %{$r->fault};
foreach $val (keys %fault) {
print "$val = $fault{$val}\n";
}
}else {
if (ref( $r->result)) {
@ret = @{$r->result};
}else {
@ret = $r->result;
}
&tools::dump_var(\@ret, 0, \*STDOUT);
}
return 1;
}
......@@ -61,6 +61,10 @@ unless ($List::use_db = &List::probe_db()) {
my $pinfo = &List::_apply_defaults();
## The process should not fork for sending mail
## Messages will be spooled instead
&mail::set_send_spool($Conf{'queue'});
## Loading all Lists at startup, in order to increase execution speed
foreach my $listname (&List::get_lists('*')){
my $list = new List ($listname);
......@@ -73,15 +77,8 @@ foreach my $listname (&List::get_lists('*')){
my $server = SOAP::Transport::HTTP::FCGI::Sympa->new();
$server->dispatch_with({'urn:do_lists' => 'sympasoap',
'urn:do_login' => 'sympasoap',
'urn:review' => 'sympasoap',
'urn:signoff' => 'sympasoap',
'urn:subscribe' => 'sympasoap',