WSDLs often import other WSDLs and XML schema.
Given a URL to a WSDL, is there a tool that will download the WSDL and all other referenced WSDLs and schemas?
Ideally, this tool would be either Java or Perl friendly.
WSDLs often import other WSDLs and XML schema.
Given a URL to a WSDL, is there a tool that will download the WSDL and all other referenced WSDLs and schemas?
Ideally, this tool would be either Java or Perl friendly.
soapUI has a WSDL content viewer, as the website describes
The Interface viewer allows relatively easy navigation and inspection of the entire contract for an imported WSDL, including all imported and included WSDL and XSD files and their contained types, definitions, etc.
http://www.soapui.org/userguide/interfaces/interfaceeditor.html
The following perl script will do what you want:
#!/usr/bin/perl
#
use strict;
use warnings;
use LWP::Simple;
sub downloadfile {
my ($url, $file) = @_;
getstore($url, $file);
}
sub getLinesMatching {
my ($file, $pattern) = @_;
open my $fh,'<',$file or die "Could not open $file: $!";
my @matching = grep /schemaLocation/,<$fh>;
my $size = @matching;
close $fh;
@matching;
}
sub processFile {
my ($url, $file) = @_;
downloadfile $url, $file;
my @lines = getLinesMatching $file,'schemaLocation';
if (@lines > 0) {
foreach my $line (@lines) {
$line =~ /schemaLocation=\"([^\"]*)/;
my ($url2) = $1;
print "$url2\n\n";
$url2 =~ /.*\/([^\/]*)/;
my ($file2) = $1;
print "$file2\n\n";
processFile ($url2, $file2);
}
}
}
my ($url) = @ARGV;
$url =~ /.*\/([^\/]*)/;
my ($base) = $1;
$base =~ s/\?/./;
print "Processing [$base] for [$url]\n\n";
processFile $url, $base;
In summary, it takes the passed in parameter as a URL to retrieve as the first file. It then scans that file for schemaLocation attributes, and downloads each of those files in a recursive manner until all schemas are located or cannot be found.
To invoke the script:
perl thisscript.perl wsdlURL
It will attempt to recursively work from the wsdl file through each imported xsd and create all the files in the current directory.
The Altova SchemaAgent tool can download, visualize and model a WSDL and multiple schemas. It's very nice when things get complex.