Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

NEED URGENT HELP IMPLEMENTING SOAP LITE

by ravi_perlmonks (Initiate)
on Jan 28, 2013 at 10:45 UTC ( #1015678=perlquestion: print w/ replies, xml ) Need Help??
ravi_perlmonks has asked for the wisdom of the Perl Monks concerning the following question:

hi guys - i am totally new to perl - have one script to make it work for my project purpose need urgent help - am getting 500 cant locate server_name - any ideas welcome thanks

#!/sbcimp/run/pd/csm/64-bit/perl/5.16.1/bin/perl use strict; use warnings; use lib '/dir.../lib'; use MIME::Base64; use SOAP::Lite; use File::MimeInfo; use File::Basename; use Data::Dumper; # the ServiceNow instance my $SNC_HOST = "https://server_name:16000"; my $base64; my $buf; my $mime_type; my $fname; print "var initialised\n"; #escape certificate check $ENV{'PERL_LWP_SSL_VERIFY_HOSTNAME'} = 0; my $line = "/file_path..../vdpsloader4.jpg"; # upload and attach a file on the local disk, base 64 encode it into a + string first #while(<FILE>){ #my $line = $_; #chomp($line); $mime_type = mimetype($line); $fname = basename($line); open(SFILE, $line) or die "$!"; while (read(SFILE, $buf, 60*57)) { $base64 .= encode_base64($buf); print "reading file\n"; # call the sub routine to attach attach_incident(); } #} sub attach_incident { # target the ecc_queue table my $soap = SOAP::Lite->proxy("$SNC_HOST/ecc_queue.do?SOAP"); my $method = SOAP::Data->name('insert')->attr({xmlns => 'http://www. +service-now.com/'}); # set the ecc_queue parameters my @params = (SOAP::Data->name(agent => 'AttachmentCreator')); push(@params, SOAP::Data->name(topic => 'AttachmentCreator') ); # identify the file name and its mime type push(@params, SOAP::Data->name(name => '$fname:application/$mime_typ +e') ); # attach to the incident, specifying its sys_id push(@params, SOAP::Data->name(source => 'incident:uniqueID') ); # set the payload to be the base 64 encoded string representation of + the file push(@params, SOAP::Data->name(payload => $base64) ); print "before WS invoke\n"; # invoke the web service print "++++++++++++\n" print "@params" my $result = $soap->call($method => @params); print Dumper($result); print "after WS invoke\n"; print_fault($result); print_result($result); } sub print_result { my ($result) = @_; if ($result->body && $result->body->{'insertResponse'}) { my %keyHash = %{ $result->body->{'insertResponse'} }; foreach my $k (keys %keyHash) { print "name=$k value=$keyHash{$k}\n"; } } } sub print_fault { my ($result) = @_; if ($result->fault) { print "faultcode=" . $result->fault->{'faultcode'} . "\n"; print "faultstring=" . $result->fault->{'faultstring'} . "\n"; print "detail=" . $result->fault->{'detail'} . "\n"; } } # use the itil user for basic auth credentials sub SOAP::Transport::HTTP::Client::get_basic_credentials { return 'user_name' => 'pswd'; }

Comment on NEED URGENT HELP IMPLEMENTING SOAP LITE
Download Code
Re: NEED URGENT HELP IMPLEMENTING SOAP LITE
by Anonymous Monk on Jan 28, 2013 at 10:51 UTC
      Hi - just to clarify i am trying to push a attachment to a front end service now server (an ITSM tool on which i work )- using the script which is been provided by service now wiki - now the server on which i am trying to run the perl (linux)hosts the web server (apache) of the same service now instance i am trying to send file on (in case it matters , not sure ) - and when i try to ping any server hostname it gives me unknown host from prompt

        "and when i try to ping any server hostname it gives me unknown host from prompt"

        Time to speak to your systems administrator.

        ...when i try to ping any server hostname it gives me unknown host from prompt

        This is a network/DNS issue. Contact your system administrator or your network administrator. There is nothing we can do here to help you there.

Re: NEED URGENT HELP IMPLEMENTING SOAP LITE
by The Perlman (Beadle) on Jan 28, 2013 at 11:37 UTC
    FYI

    All CAPITAL LETTERS means shouting.

    Plus "URGENT" and "HELP" will make many people wanting to ignore your posts.

    - Ron
    UPDATE: reduced to simple netiquette feedback.
      thank u all for ur help will do and might start learning it as well - looks pretty good this lang imo

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1015678]
Approved by vinoth.ree
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2014-07-28 05:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (187 votes), past polls