4 use vars qw($DEBUG $VERSION @uris $AUTOLOAD %schemas);
5 use SOAP::Lite 0.71 #+trace => debug, objects
12 @uris = qw( CPECollection AppCatalog AdminService CPESearch Version Applications
13 CPEAccess ApplicationsV2
18 Net::Soma - Perl client interface to SOMA iWireless platform
23 use Net::Soma qw( AttributeInstance FeatureInstance ApplicationInstance
24 ChoiceItem AttributeDef FeatureDef ApplicationDef
25 ApplicationDefV2 FeatureDefV2 AttributeDefV2 CPEInfoDefV2
26 CPESearchStruct CPESearchResult CPEInfo CPEInfoDef
28 NoSuchCPEException DataAccessException InternalFault
29 BadAppParameterException BadAppParameterExceptionV2
30 NoSuchAppException NoSuchFeatureException
31 NoSuchAttributeException BadCPEParameterException
32 ActiveApplicationsException );
34 $soma = new Net::Soma { url => 'https://soma.example.net:8088/ossapi/services',
35 namespace => 'AppCatalog',
38 $err_or_som = $soma->getApplicationDefinitions();
40 if (ref($err_or_som)){
41 my $result = $err_or_som->result;
42 foreach my $definition (@$result) {
43 print $definition->name, "\n";
46 print "$err_or_som\n";
51 Net::Soma is a module implementing a Perl interface to SOMA's iWireless
52 SOAP interface (ossapi). It is compatible with release 1.5 of that software
53 and requires the WSDLs from SOMA.
55 Net::Soma enables you to simply access the SOAP interface of your SOMA
56 networks softair platform server.
60 Import the Net::Soma module with
62 use Net::Soma (@list_of_classes);
64 Net::Soma will create any of the following classes for you
66 AttributeInstance FeatureInstance ApplicationInstance ChoiceItem
67 AttributeDef FeatureDef ApplicationDef ApplicationDefV2 FeatureDefV2
68 AttributeDefV2 CPEInfoDefV2 CPESearchStruct CPESearchResult CPEInfo
69 CPEInfoDef HardwarePort NoSuchCPEException DataAccessException InternalFault
70 BadAppParameterException BadAppParameterExceptionV2 NoSuchAppException
71 NoSuchFeatureException NoSuchAttributeException BadCPEParameterException
72 ActiveApplicationsException
80 my @classlist = qw( AttributeInstance FeatureInstance ApplicationInstance
81 ChoiceItem AttributeDef FeatureDef ApplicationDef
82 ApplicationDefV2 FeatureDefV2 AttributeDefV2 CPEInfoDefV2
83 CPESearchStruct CPESearchResult CPEInfo CPEInfoDef
85 NoSuchCPEException DataAccessException InternalFault
86 BadAppParameterException BadAppParameterExceptionV2
87 NoSuchAppException NoSuchFeatureException
88 NoSuchAttributeException BadCPEParameterException
89 ActiveApplicationsException
91 my (%EXPORT_OK) = map { $_ => 1 } @classlist;
94 no strict 'refs'; #hmmm force 'use' of all to be serialized?
95 foreach my $class (@classlist) {
97 *{"SOAP::Serializer::as_$class"} = sub {
98 my ($self, $value, $name, $type, $attr) = @_;
100 $self->register_ns("urn:ossapi.services.core.soma.com", "netsoma");
101 $self->encode_object( \SOAP::Data->value(
102 SOAP::Data->name($name => map { SOAP::Data->name($_ => $value->{$_}) }
105 ), $name, $type, {'xsi:type' => "netsoma:$class", %$attr});
108 *{"SOAP::Serializer::as_ArrayOf$class"} = sub {
109 my ($self, $value, $name, $type, $attr) = @_;
111 $self->register_ns("urn:ossapi.services.core.soma.com", "netsoma");
113 $self->encode_object( \SOAP::Data->value(
114 SOAP::Data->name($name => map { SOAP::Data->name(item => $_) }
117 ), $name, $type, {'xsi:type' => "netsoma:ArrayOf$class", %$attr});
119 $self->encode_object( [], $name, $type, {'xsi:type' => "netsoma:ArrayOf$class", %$attr});
128 foreach $class ( map { $_, "ArrayOf$_" }
129 grep { exists( $EXPORT_OK{$_} )
130 or die "$_ is not exported by module $me"
136 *{"$class\::NEW"} = sub {
138 my $class = ref($proto) || $proto;
140 return bless($self, $class);
142 *{"$class\::AUTOLOAD"} = sub {
143 my $field = $AUTOLOAD;
145 return if $field eq 'DESTROY';
146 if ( defined($_[1]) ) {
147 $_[0]->{$field} = $_[1];
155 # $INC{"$me.pm"} =~ /^(.*)\.pm$/;
158 # $schemas{$_."Service"} = SOAP::Schema
159 # ->schema_url("file:$me/wsdls/$_.wsdl")
160 # ->parse->services->{$_."Service"};
171 Creates a new Soma object. HASHREF should contain the keys url and namespace
172 for the URL of the Soma SOAP proxy and the namespace of the methods you would
173 like to call. You may optionally define the key die_on_fault to cause that
174 behavior for methods.
180 my $class = ref($proto) || $proto;
184 $schemas{$_."Service"} = SOAP::Schema
185 ->schema_url($self->{url}."$_?wsdl")
186 ->parse->services->{$_."Service"};
189 return bless($self, $class);
194 All Soma methods may be invoked as methods of the Net::Soma object.
195 The return value is either the fault string in the event of an error
196 or a SOAP::SOM object.
198 If the option die_on_fault was set for the Net::Soma object, then
199 instead the method dies on error and returns the result component
200 of the SOAP::SOM object on success.
205 my $self = shift; #hmmm... test this?
207 my $method = $AUTOLOAD;
209 return if $method eq 'DESTROY';
212 my $uri = $self->{namespace};
213 $uri =~ s/Service$//;
214 my $soap = SOAP::Lite
218 -> proxy($self->{url});
220 # local *SOAP::Transport::HTTP::Client::get_basic_credentials = sub {
221 # return $self->{user} => $self->{password};
226 $soap->$method( map {
228 $schemas{$self->{namespace}}{$method}{'parameters'}[$param++];
229 my ($pre,$type) = SOAP::Utils::splitqname($paramdata->type);
230 SOAP::Data->name($paramdata->name => $_ )
231 ->type(${[SOAP::Utils::splitqname($paramdata->type)]}[1]) } @_
236 if ($self->{die_on_fault}){
237 die $som->faultstring;
239 return $som->faultstring;
242 if ($self->{die_on_fault}){
250 die "Net::Soma failed to $method for $self->{namespace} at " . $self->{url};
258 SOAP::Lite, SOAP::SOM
260 http://www.somanetworks.com/ for information about SOMA and iWireless.
262 http://www.sisd.com/freeside/ for the ISP billing and provisioning system
263 which provoked the need for this module.
267 Namespace promiscuous.
268 Lax handling of arguments and return values.
269 In fact, calling a bogus method with arguments causes complaints about
270 accessing methods on undefined values (at line 233, paramdata->name)
272 Quite probably others. Use at your own risk.
274 =head1 AUTHOR AND COPYRIGHT
276 Copyright (c) 2008 Jeff Finucane jeff-net-soma@weasellips.com
278 This library is free software; you can redistribute it and/or modify
279 it under the same terms as Perl itself.
281 This software is neither authorized, sponsored, endorsed, nor supported