Linux 使用powershell的最简单的XML-RPC查询示例?
希望简化甚至“简化”这一点: 从Linux 使用powershell的最简单的XML-RPC查询示例?,linux,powershell,microservices,xml-rpc,Linux,Powershell,Microservices,Xml Rpc,希望简化甚至“简化”这一点: 从perl中的脚本改编: #!/usr/bin/perl # # Get an RPC key assigned on the "Account Info" page on https://www.upcdatabase.com/ # Then substitute your own RPC key for $key below. # # Usage examples: # perl_example_new.pl test # perl_
perl
中的脚本改编:
#!/usr/bin/perl
#
# Get an RPC key assigned on the "Account Info" page on https://www.upcdatabase.com/
# Then substitute your own RPC key for $key below.
#
# Usage examples:
# perl_example_new.pl test
# perl_example_new.pl help
# perl_example_new.pl lookup upc 012000000850
# perl_example_new.pl lookup ean 0012000000850
use Frontier::Client;
use Data::Dumper;
use strict;
my $server_name = 'www.upcdatabase.com';
my $key = '445d...aa3';
my $server = Frontier::Client->new( 'url' => 'https://' . $server_name . '/xmlrpc', debug => 0, );
my $method = shift;
my $result = $server->call($method, { rpc_key => $key, @ARGV } );
print Dumper($result);
__END__
使用REPL
控制台适应powershell
:
PS /home/nicholas/powershell>
PS /home/nicholas/powershell> Get-Help Send-XmlRpcRequest -Examples
NAME
Send-XmlRpcRequest
SYNOPSIS
Send a XML RPC Request
-------------------------- EXAMPLE 1 --------------------------
PS > Send-XmlRpcRequest -Url "example.com" -MethodName "updateName" -Params @('oldName', 'newName')
---------
Description
Calls a method "updateName("oldName", "newName")" on the server example.com
PS /home/nicholas/powershell>
PS /home/nicholas/powershell> Send-XmlRpcRequest -Url "www.upcdatabase.com" -MethodName "012000000850" -Params @('fjkdlsfjd')
Exception: /home/nicholas/.local/share/powershell/Modules/XmlRpc/1.0.1.1/XmlRpc.psm1:323
Line |
323 | $doc.LoadXml($response)
| ~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "LoadXml" with "1" argument(s): "Root element is missing."
PS /home/nicholas/powershell>
或者使用脚本文件
#!/usr/bin/perl
#
# Get an RPC key assigned on the "Account Info" page on https://www.upcdatabase.com/
# Then substitute your own RPC key for $key below.
#
# Usage examples:
# perl_example_new.pl test
# perl_example_new.pl help
# perl_example_new.pl lookup upc 012000000850
# perl_example_new.pl lookup ean 0012000000850
use Frontier::Client;
use Data::Dumper;
use strict;
my $server_name = 'www.upcdatabase.com';
my $key = '445d...aa3';
my $server = Frontier::Client->new( 'url' => 'https://' . $server_name . '/xmlrpc', debug => 0, );
my $method = shift;
my $result = $server->call($method, { rpc_key => $key, @ARGV } );
print Dumper($result);
__END__
PS /home/nicholas/powershell>
PS /home/nicholas/powershell> Get-Help Send-XmlRpcRequest -Examples
NAME
Send-XmlRpcRequest
SYNOPSIS
Send a XML RPC Request
-------------------------- EXAMPLE 1 --------------------------
PS > Send-XmlRpcRequest -Url "example.com" -MethodName "updateName" -Params @('oldName', 'newName')
---------
Description
Calls a method "updateName("oldName", "newName")" on the server example.com
PS /home/nicholas/powershell>
PS /home/nicholas/powershell> Send-XmlRpcRequest -Url "www.upcdatabase.com" -MethodName "012000000850" -Params @('fjkdlsfjd')
Exception: /home/nicholas/.local/share/powershell/Modules/XmlRpc/1.0.1.1/XmlRpc.psm1:323
Line |
323 | $doc.LoadXml($response)
| ~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "LoadXml" with "1" argument(s): "Root element is missing."
PS /home/nicholas/powershell>