4 use vars qw($DEBUG $VERSION @uris %services $AUTOLOAD %schemas);
11 @uris = qw(CustomerIfService NetworkIfService LogEventIfService);
15 Net::Prizm - Perl client interface to Motorola Canopy Prizm
20 use Net::Prizm qw(CustomerInfo LogEventInfo
21 ClientDevice ConfigurationTemplate ElementLinkInfo
22 Network PerformanceData);
24 $prizm = new Net::Prizm { url => 'https://prizm.example.net:8443/prizm/nbi',
25 namespace => 'CustomerIfService',
26 username => 'prizmuser',
27 password => 'associatedpassword',
30 $err_or_som = $prizm->getCustomers(['import_id'], ['50'], ['<']);
32 if (ref($err_or_som)){
33 my $result = $err_or_som->result;
34 foreach my $customer (@$result) {
35 print $customer->contact, "\n";
38 print "$err_or_som\n";
43 Net::Prizm is a module implementing a Perl interface to Motorola's Canopy
44 Prizm SOAP interface. It is compatible with version 3.0r1 of that software
45 and requires the WSDL from Motorola.
47 Net::Prizm enables you to simply access the SOAP interface of your Prizm
52 Import the Net::Prizm module with
54 use Net::Prizm (@list_of_classes);
56 Net::Prizm will create any of the following classes for you
58 CustomerInfo LogEventInfo PrizmElement ClientDevice ConfigurationTemplate
59 ElementLinkInfo Network PerformanceData
67 my (%EXPORT_OK) = map { $_ => 1 } qw( CustomerInfo LogEventInfo PrizmElement
68 ClientDevice ConfigurationTemplate
69 ElementLinkInfo Network
72 foreach $class (grep { exists( $EXPORT_OK{$_} )
73 or die "$_ is not exported by module $me"
77 *{"$class\::NEW"} = sub {
79 my $class = ref($proto) || $proto;
81 return bless($self, $class);
83 *{"$class\::AUTOLOAD"} = sub {
84 my $field = $AUTOLOAD;
86 return if $field eq 'DESTROY';
87 if ( defined($_[1]) ) {
88 $_[0]->{$field} = $_[1];
96 $INC{"$me.pm"} =~ /^(.*)\.pm$/;
99 $schemas{$_} = SOAP::Schema
100 ->schema_url("file:$me/wsdls/$_.wsdl")
101 ->parse->services->{$_};
112 Creates a new Prizm object. HASHREF should contain the keys url, namespace,
113 username, and password for the URL of the Prizm SOAP proxy, the namespace
114 of the methods you would like to call, and the username and password for
115 basic authentication.
121 my $class = ref($proto) || $proto;
123 return bless($self, $class);
128 All Prizm methods may be invoked as methods of the Net::Prizm object.
129 The return value is either the fault string in the event of an error
130 or a SOAP::SOM object.
135 my $self = shift; #hmmm... test this?
137 my $method = $AUTOLOAD;
139 return if $method eq 'DESTROY';
141 my $soap = SOAP::Lite
144 -> uri($self->{namespace})
145 -> proxy($self->{url});
147 local *SOAP::Transport::HTTP::Client::get_basic_credentials = sub {
148 return $self->{user} => $self->{password};
151 local *SOAP::Serializer::as_ArrayOf_xsd_string = sub {
152 my ($self, $value, $name, $type, $attr) = @_;
154 $name ||= $self->gen_name;
155 $self->encode_object(\SOAP::Data->value(
156 SOAP::Data->name('string' => @{$value})->type('string')
161 local *SOAP::Serializer::as_ArrayOf_xsd_int = sub {
162 my ($self, $value, $name, $type, $attr) = @_;
164 $name ||= $self->gen_name;
165 $self->encode_object(\SOAP::Data->value(
166 SOAP::Data->name('int' => @{$value})->type('int')
170 local *SOAP::Serializer::as_CustomerInfo = sub {
171 my ($self, $value, $name, $type, $attr) = @_;
174 'importId' => 'string',
175 'customerId' => 'int',
176 'customerName' => 'string',
177 'customerType' => 'string',
178 'address1' => 'string',
179 'address2' => 'string',
182 'zipCode' => 'string',
183 'workPhone' => 'string',
184 'homePhone' => 'string',
185 'mobilePhone' => 'string',
188 'extraFieldNames' => 'impl:ArrayOf_xsd_string',
189 'extraFieldValues' => 'impl:ArrayOf_xsd_string',
190 'elementIds' => 'impl:ArrayOf_xsd_int',
194 foreach my $key (keys %$value){
195 my $to_encode = $value->{$key};
196 push @result, SOAP::Data->name($key => $to_encode)->type($schema->{$key});
199 return $self->encode_object(\SOAP::Data->value(
200 SOAP::Data->name($name => @result)), $name,
202 {'xsi:type' => 'impl:CustomerInfo', %$attr});
207 $soap->$method( map {
209 $schemas{$self->{namespace}}{$method}{'parameters'}[$param++];
210 SOAP::Data->name($paramdata->name => $_ )
211 ->type(${[SOAP::Utils::splitqname($paramdata->type)]}[1]) } @_
216 return $som->faultstring;
222 "Net::Prizm failed to $method for $self->{namespace} at " . $self->{url};
230 SOAP::Lite, SOAP::SOM
232 http://motorola.canopywireless.com/ for information about Canopy and
235 http://www.sisd.com/freeside/ for the ISP billing and provisioning system
236 which provoked the need for this module.
240 No explicit handling of types other than CustomerInfo.
241 Namespace promiscuous.
242 Lax handling of arguments and return values.
244 Quite probably others. Use at your own risk.
246 =head1 AUTHOR AND COPYRIGHT
248 Copyright (c) 2006 Jeff Finucane jeff-net-prizm@weasellips.com
250 This library is free software; you can redistribute it and/or modify
251 it under the same terms as Perl itself.
253 WDSL files copyright Motorola Inc. which reserves all rights.
255 This software is neither authorized, sponsored, endorsed, nor supported