Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

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'; }

In reply to NEED URGENT HELP IMPLEMENTING SOAP LITE by ravi_perlmonks

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (8)
    As of 2014-09-21 08:18 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (167 votes), past polls