#!/usr/bin/perl -w
use SOAP::Lite trace=>'debug';
#use SOAP::Lite;
use Data::Dumper;
use strict;
# Perl sub routine to call Service Desk login method
# and specify Service Desk Web Services end point
sub login_get_SID {
# Edit $server, $user and $pw as needed.
my $server = '192.168.1.152:8180';
my $endpoint = '/axis/services/USD_R11_WebService?WSDL';
my $user = ''; #user id
my $pw = ''; #user pwd
my $wsdl = 'http://' . $server . $endpoint;
my $service = SOAP::Lite->service($wsdl);
my $sid = $service->login($user, $pw);
return ($service, $sid);
}
# Always a best practice to call logout() when done
sub logout {
my ($service, $sid) = @_;
$service->logout($sid)
}
# method to retrieve all Incident Areas
sub retrieveCategories
{
my ($service, $sid, $service_name) = @_;
my $method = SOAP::Data->uri('http://www.ca.com/UnicenterServicePl
+us/ServiceDesk')->name('doSelect');
# Attributes for object to be created can be pulled
# from majic files.
my @params = ( SOAP::Data->name("sid" => $sid),
SOAP::Data->name("objectType" => 'pcat'),
SOAP::Data->name("whereClause" => "sym like 'Appl%
+'"),
SOAP::Data->name("maxRows" => "1"),
SOAP::Data->name("attributes" =>
\SOAP::Data->value(
SOAP::Data->name("string" => "sym"),
SOAP::Data->name("string" => 'description')
)
),
);
#print "dumper: ".Dumper(@params)."\n";
my $result = $service->call($method => @params);
print "----result method call ---\n".$result->result."----- end re
+sult ----\n";
print "----valueof method call ----\n".$result->valueof('//AttrNam
+e[1]')."----- end valueof ----\n";
return ($result);
}
# Main calls
my ($service, $sid) = login_get_SID();
retrieveCategories($service, $sid);
logout($service, $sid);
Here is the output from retrieveCategories() subroutine:
----result method call ---
<?xml version="1.0" encoding="UTF-8"?>
<UDSObjectList>
<UDSObject>
<Handle>pcat:5103</Handle>
<Attributes>
<Attribute DataType="2002">
<AttrName>sym</AttrName>
<AttrValue>Applications</AttrValue>
</Attribute>
<Attribute DataType="2002">
<AttrName>description</AttrName>
<AttrValue>Applications</AttrValue>
</Attribute>
</Attributes>
</UDSObject>
</UDSObjectList>
----- end result ----
----valueof method call ----
----- end valueof ----
This section is the full trace output.
SOAP::Transport::HTTP::Client::send_receive: POST http://192.168.1.152
+:8180/axis/services/USD_R11_WebService HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
Content-Length: 713
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:wsdlsoap="h
+ttp://schemas.xmlsoap.org/wsdl/soap/" xmlns:apachesoap="http://xml.ap
+ache.org/xml-soap" soap:encodingStyle="http://schemas.xmlsoap.org/soa
+p/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" x
+mlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:impl="http://www.c
+a.com/UnicenterServicePlus/ServiceDesk" xmlns:xsi="http://www.w3.org/
+2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/so
+ap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body
+><impl:login><username xsi:type="xsd:string">ServiceDesk</username><p
+assword xsi:type="xsd:string">Un1c3nt3r</password></impl:login></soap
+:Body></soap:Envelope>
SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK
Connection: close
Date: Mon, 15 Sep 2008 18:58:44 GMT
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Client-Date: Mon, 15 Sep 2008 18:58:45 GMT
Client-Peer: 192.168.1.152:8180
Client-Response-Num: 1
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel
+ope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://
+www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<loginResponse xmlns="http://www.ca.com/UnicenterServicePlus/Service
+Desk">
<loginReturn xsi:type="xsd:int" xmlns="">639087957</loginReturn>
</loginResponse>
</soapenv:Body>
</soapenv:Envelope>
SOAP::Transport::HTTP::Client::send_receive: POST http://192.168.1.152
+:8180/axis/services/USD_R11_WebService HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
User-Agent: SOAP::Lite/Perl/0.710.05
Content-Length: 1000
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:wsdlsoap="h
+ttp://schemas.xmlsoap.org/wsdl/soap/" xmlns:apachesoap="http://xml.ap
+ache.org/xml-soap" xmlns:namesp7="http://www.ca.com/UnicenterServiceP
+lus/ServiceDesk" soap:encodingStyle="http://schemas.xmlsoap.org/soap/
+encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xml
+ns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.o
+rg/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org
+/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:B
+ody><namesp7:doSelect xmlns:namesp7="http://www.ca.com/UnicenterServi
+cePlus/ServiceDesk"><sid xsi:type="xsd:int">639087957</sid><objectTyp
+e xsi:type="xsd:string">pcat</objectType><whereClause xsi:type="xsd:s
+tring">sym like 'Appl%'</whereClause><maxRows xsi:type="xsd:int">1</m
+axRows><attributes><string xsi:type="xsd:string">sym</string><string
+xsi:type="xsd:string">description</string></attributes></namesp7:doSe
+lect></soap:Body></soap:Envelope>
SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK
Connection: close
Date: Mon, 15 Sep 2008 18:58:44 GMT
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Client-Date: Mon, 15 Sep 2008 18:58:46 GMT
Client-Peer: 192.168.1.152:8180
Client-Response-Num: 1
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel
+ope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://
+www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<doSelectResponse xmlns="http://www.ca.com/UnicenterServicePlus/Serv
+iceDesk">
<doSelectReturn xmlns=""><?xml version="1.0" encoding=
+"UTF-8"?>
<UDSObjectList>
<UDSObject>
<Handle>pcat:5103</Handle>
<Attributes>
<Attribute DataType="2002">
<AttrName>sym</AttrName>
<AttrValue>Applications</AttrValue>
</Attribute>
<Attribute DataType="2002">
<AttrName>description</AttrName>
<AttrValue>Applications</AttrValue>
</Attribute>
</Attributes>
</UDSObject>
</UDSObjectList>

</doSelectReturn>
</doSelectResponse>
</soapenv:Body>
</soapenv:Envelope>
Use of uninitialized value in concatenation (.) or string at C:\dev\us
+dservices\perlmonk_sample.pl line 54.
SOAP::Transport::HTTP::Client::send_receive: POST http://192.168.1.152
+:8180/axis/services/USD_R11_WebService HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
User-Agent: SOAP::Lite/Perl/0.710.05
Content-Length: 648
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:wsdlsoap="h
+ttp://schemas.xmlsoap.org/wsdl/soap/" xmlns:apachesoap="http://xml.ap
+ache.org/xml-soap" soap:encodingStyle="http://schemas.xmlsoap.org/soa
+p/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" x
+mlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:impl="http://www.c
+a.com/UnicenterServicePlus/ServiceDesk" xmlns:xsi="http://www.w3.org/
+2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/so
+ap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body
+><impl:logout><sid xsi:type="xsd:int">639087957</sid></impl:logout></
+soap:Body></soap:Envelope>
SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK
Connection: close
Date: Mon, 15 Sep 2008 18:58:46 GMT
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Client-Date: Mon, 15 Sep 2008 18:58:47 GMT
Client-Peer: 192.168.1.152:8180
Client-Response-Num: 1
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel
+ope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://
+www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<logoutResponse xmlns="http://www.ca.com/UnicenterServicePlus/Servic
+eDesk"/>
</soapenv:Body>
</soapenv:Envelope>
Thanks,
fujiman |