您好,
我在Perl脚本,需要转换到C#。我想在我的C#Windows窗体应用程序中使用它。任何不知道如果有一个程序转换的Perl C#
在此先感谢!
----------------------
:7762422 |会员use MIME::Base64;
use strict;
use SOAP::Lite;
# Instance
my $SNC_HOST = "http://website.com";
my $base64;
my $buf;
# upload and attach a file on the local disk, base 64 encode it into a string first
open(FILE, "c:/number_test.xls") or die "$!";
while (read(FILE, $buf, 60*57)) {
$base64 .= encode_base64($buf);
}
# 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://website.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 => 'number_test.xls:application/vnd.ms-excel') );
# attach to the incident, specifying its sys_id
push(@params, SOAP::Data->name(source => 'incident:dd90c5d70a0a0b39000aac5aee704ae8') );
# set the payload to be the base 64 encoded string representation of the file
push(@params, SOAP::Data->name(payload => $base64) );
# invoke the web service
my $result = $soap->call($method => @params);
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 'itil' => 'itil';
}