Thread PHP Skript Konvertieren in Perl (10 answers)
Opened by segler at 2010-06-17 16:08

topeg
 2010-06-17 17:19
#138436 #138436
User since
2006-07-10
2611 Artikel
BenutzerIn

user image
Ich kann nicht immer sagen was zurück kommt.
Also ohne es getestet zu haben:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/perl
use strict;
use warnings;
use SOAP::Lite;

# connection settings
my %conf=();
$conf{SOAP_PROTO}='http';
$conf{SOAP_HOST}='172.16.8.15';
$conf{SOAP_PORT}='448';
$conf{SOAP_FORMAT}='%s://%s:%d/SOAP';
$conf{SOAP_WSDL_FILE}='../soapapi.wsdl';

# defining some useful constants.
$conf{REQUIRED_API_VERSION}="2.6.0";
$conf{VAP_GLOBAL}="Global";
$conf{EQUIPMENT_ID}="EQPT_1";
$conf{COUNTRY_CODE}="CANADA";

# values
$conf{USER}="Test01";
$conf{PASS}="123456";


if ($conf{SOAP_PROTO}=~/^https?$/)
{
  my $url = sprintf($conf{SOAP_FORMAT},
                    $conf{SOAP_PROTO},
                    $conf{SOAP_HOST},
                    $conf{SOAP_PORT});

  my $soap = SOAP::Lite->uri($conf{SOAP_WSDL_FILE})->proxy($url);
  my $rc = $soap->GetSOAPVersion();
  test_error($rc);

  if ($rc->result!~/\Q$conf{REQUIRED_API_VERSION}/)
  { die sprintf( "Incorrect SOAP API version found: <%s> - expecting <%s>\n",  $rc->version, $conf{REQUIRED_API_VERSION} ); }

  print("AddUserAccount\n");
  $rc = $soap->AddUserAccount("username" => $conf{USER},
                              "password" => $conf{PASS},
                              "activeState" => 1,
                              "accessControlledState" => 1);
  test_error($rc);


  print("UpdateVirtualSCLocalUser\n");
  $rc = $soap->UpdateVirtualSCLocalUser("Internetzugang",$conf{USER},$conf{PASS},60,0,1);
  test_error($rc);
}
else
{ printf("%s not supported\n",$conf{SOAP_PROTO}); }


sub test_error
{
  my $rc=shift;
  die(sprintf("ERROR(%s) %s\n",$rc->faultcode,$rc->faultstring)) if($rc->fault);
}


EDIT: Code korrigiert.
Last edited: 2010-06-17 18:09:34 +0200 (CEST)

View full thread PHP Skript Konvertieren in Perl