ISPConfig Remoting Framework using perls SOAP::Lite

Discussion in 'Tips/Tricks/Mods' started by olaus, Mar 27, 2006.

  1. olaus

    olaus New Member

    hi folks,

    if anyones interessted in using the ISPConfig Remoting Framework with SOAP::Lite here's some example code that downloads a list of all resellers.

    ciao
    arnim

    Code:
    #!/usr/bin/perl -w
    # contact ISPconfig SOAP-remote-extension using SOAP::Lite
    
    my ( @params );
    my ( $obj );
    
    use SOAP::Lite;
    
    my $soap = SOAP::Lite
        -> proxy('https://127.0.0.1:81/remote/index.php') ;
    
    @params = (
      SOAP::Data->name(username => 'USER'),
      SOAP::Data->name(password => 'PASSWORD'),
    );
    
    $obj = $soap->call(login => @params);
    
    if ( $obj->faultstring ) {
            die "error: ".$obj->faultstring ;
    }
    
    $session_id = $obj->result;
    
    @params = (
      SOAP::Data->name(sid => $session_id ),
      SOAP::Data->name(module => 'reseller'),
      SOAP::Data->name(function => 'reseller_list'),
      SOAP::Data->name(params => ''),
    );
    
    # get object:
    $obj = $soap->call(service => @params);
    
    if ( $obj->faultstring ) {
            die "error: ".$obj->faultstring ;
    }
    $result = $obj->result;
    
    # show results:
    foreach my $hash_name ( keys %{$result} ) {
            ($hash_ref) = $result->{ $hash_name };
            print "hash_name: $hash_name - hash_ref: $hash_ref \n";
            foreach my $key (sort keys %{$hash_ref}) {
           }
    }
    
    # Adding a client
    @kunden_params = (
            SOAP::Data->name(reseller_title => 'test_anbieter'),
            SOAP::Data->name(kunde_title => 'kunde_title'),
            SOAP::Data->name(kunde_anrede => 'kunde_anrede'),
            SOAP::Data->name(kunde_firma => 'test_anbieter'),
            SOAP::Data->name(kunde_vorname => 'test_anbieter'),
            SOAP::Data->name(kunde_name => 'test_anbieter'),
            SOAP::Data->name(kunde_strasse => 'test_anbieter'),
            SOAP::Data->name(kunde_plz => '12345'),
            SOAP::Data->name(kunde_ort => 'test_anbieter'),
            SOAP::Data->name(kunde_land => 'test_anbieter'),
            SOAP::Data->name(kunde_telefon => 'test_anbieter'),
            SOAP::Data->name(kunde_fax => 'test_anbieter'),
            SOAP::Data->name(kunde_email => 'test_anbieter'),
            SOAP::Data->name(kunde_internet => 'test_anbieter'),
            SOAP::Data->name(webadmin_user => 'test_anbieter'),
            SOAP::Data->name(webadmin_passwort => 'test_anbieter'),
            SOAP::Data->name(kunde_province => 'test_anbieter'),
    );
    
    @params = (
      SOAP::Data->name(sid => $session_id ),
      SOAP::Data->name(module => 'kunde'),
      SOAP::Data->name(function => 'kunde_add'),
      SOAP::Data->name(params => \SOAP::Data->value(
              SOAP::Data->name(params => @kunden_params ),
                                                    )
                                            )
    );
    
    $customer_id = $soap->call(service => @params);
    
    print "customer_id: $customer_id\n";
    
    if ( $customer_id->faultstring ) {
            die "error: ".$customer_id->faultstring ;
    }
    
    # over and out
    @params = (
      SOAP::Data->name(sid => $session_id ),
    );
    $obj = $soap->call(logout => @params);
    
    if ( $obj->faultstring ) {
            die "error: ".$obj->faultstring ;
    }
    
     
    Last edited: Mar 27, 2006

Share This Page