Skip to content

Instantly share code, notes, and snippets.

@sheeju
Forked from dex4er/soap-calculator-client.pl
Last active August 29, 2015 14:07
Show Gist options
  • Save sheeju/babe3255fce2995ddf85 to your computer and use it in GitHub Desktop.
Save sheeju/babe3255fce2995ddf85 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use warnings;
use strict;
use XML::Compile::WSDL11;
use XML::Compile::SOAP11;
use XML::Compile::Transport::SOAPHTTP;
use HTTP::Tiny;
use YAML::Tiny;
my $wsdl = XML::Compile::WSDL11->new(
HTTP::Tiny->new->get('http://soaptest.parasoft.com/calculator.wsdl')->{content},
);
use URI; #
my $uri = URI->new($wsdl->endPoint); # additional HTTP authorization
$uri->userinfo('user:password'); #
#
my $http = XML::Compile::Transport::SOAPHTTP->new( # setting new transport
address => $uri->as_string, # with explicit address
); #
#
my $transport = $http->compileClient( # SOAPAction header
action => 'add', #
); #
my $call = $wsdl->compileClient(
operation => 'add',
sloppy_floats => 1,
transport => $transport, # optional for default transport
# transport => sub { die $_[0]->toString }, # debugging: only XML output
);
my $request = {
x => 2,
y => 2,
};
my ($response, $trace) = $call->($request);
print "---\n";
$trace->printRequest;
print Dump({Data => $request}), "\n";
print "---\n";
$trace->printResponse;
print Dump({Data => $response}), "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment