Skip to content

Commit

Permalink
New admits non-base URLs to non-standard WSDL descriptors.
Browse files Browse the repository at this point in the history
This was suggested by Elena Bolshakova <elena@cpan.org>. She cited
these URLs explaining why this is relevant:

* http://www.j-tricks.com/1/post/2010/10/soap-rpc-plugin.html
* https://answers.atlassian.com/questions/43386/closed-how-can-i-add-my-own-soap-api-in-jira
  • Loading branch information
gnustavo committed Jul 12, 2012
1 parent 43a9ac8 commit 7b74474
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions lib/JIRA/Client.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package JIRA::Client;
use Carp;
use Data::Util qw(:check);
use SOAP::Lite;
use URI;

=head1 SYNOPSIS
Expand Down Expand Up @@ -97,19 +98,33 @@ distinguish them and we can avoid future name clashes.
=method B<new> JIRAURL, USER, PASSWD [, <SOAP::Lite arguments>]
The JIRA::Client constructor requires three arguments. JIRAURL is
JIRA's base URL from which will be constructed it's WSDL descriptor as
C<$JIRAURL/rpc/soap/jirasoapservice-v2?wsdl>. USER and PASSWD are the
credentials that will be used to authenticate into JIRA. Any other
arguments will be passed to the L<SOAP::Lite> object that will be
created to talk to JIRA.
C<JIRAURL> can be simply the JIRA server's base URL, with no path,
query or fragment (e.g., C<https://jira.example.net/>). In this case,
the default WSDL descriptor path
(C</rpc/soap/jirasoapservice-v2?wsdl>) will be appended to it in order
to construct the underlying SOAP::Lite object.
If your JIRA instance has a non-standard path to a WSDL service, you
should pass the complete URL to it.
C<USER> and C<PASSWD> are the credentials that will be used to
authenticate into JIRA.
Any other arguments will be passed to the L<SOAP::Lite> object that
will be created to talk to JIRA.
=cut

sub new {
my ($class, $base_url, $user, $pass, @args) = @_;

my $soap = SOAP::Lite->proxy("$base_url/rpc/soap/jirasoapservice-v2?wsdl", @args);
my $url = URI->new($base_url);
if ($url->path_query() =~ m:^/*$:) {
# Append the default WSDL resource if the URL does not specify any
$url->path_query('/rpc/soap/jirasoapservice-v2?wsdl');
}

my $soap = SOAP::Lite->proxy($url->as_string(), @args);

# Make all scalars be encoded as strings by default.
%{$soap->typelookup()} = (default => [0, sub {1}, 'as_string']);
Expand Down

0 comments on commit 7b74474

Please sign in to comment.