lib/WSDL/XML/Generator.pm

filter: Statementstmt 88.2% 15 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 91.3% 21 / 23 CC 1 SCAR 0.5
CC
1
Cov
88%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
↑ Summary
1 package WSDL::XML::Generator;
2
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 =head1 NAME
8
9 WSDL::XML::Generator - The way WSDL::XML::Generator is creating a lots of xml with WSDL file by wsdl name and type name.
10
11 =head1 VERSION
12
13 Version 0.02
14
15 =cut
16
17 our $VERSION = '0.02';
18
19 =head1 SYNOPSIS
20
21 1. Just find out Type in WSDL file, write test xml sample, it may be modified to your enviroment, because the generated xml file not related message/portType/service, in here, i supposed the portType type and message are having the same name.
22
23 2. Secondly, the WSDL file always has xsd schema file that defined all data types, you need fill the xml content by the those types.
24
25 use WSDL::XML::Generator qw( write list_data_node );
26 write('t/test.wsdl');
27 list_data_node('t/test.wsdl');
28
29 =head1 EXPORT
30
31 write list_data_node
32
33 =head1 SUBROUTINES/METHODS
34
35 =head2
36
37 write()
38
39 list_data_node()
40
41 =cut
42
43 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 1 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 0 ▶use File::Slurp qw(read_file write_file);
Subroutine BEGIN: called CC=1 SCAR=2.6
46 use XML::Simple qw(XMLin);
47 our @ISA = qw( Exporter );
48 our @EXPORT = qw( write list_data_node );
49
50 sub write {
51 my $wsdl_file = shift;
52 my $element_name;
53 my ($file_name_prex) = $wsdl_file =~ /(\w+)\.wsdl/;
54 my @lines = read_file($wsdl_file);
55 foreach (@lines) {
56 if ( /<types>/ .. /<\/types>/ ) {
57 if ( /<xsd:element name="(\w+)">/ .. /<\/xsd:element>/ ) {
58 $element_name =
59 /<xsd:element name="(\w+)">/ ? $1 : $element_name;
60 my $output_xml = $file_name_prex . '_' . $element_name . '.xml';
61 if ( /<xsd:sequence>/ .. /<\/xsd:sequence>/ ) {
62 if (/<xsd:element name="(\w+)" type="(.*)" \/>/) {
63 my $name = $1;
64 write_file( $output_xml, { append => 1 },
65 "<$name>$name<\/$name>" );
66 }
67 }
68 }
69 }
70 }
71 return 1;
72 }
73
74 sub list_data_node {
75 my $wsdl_file = shift;
76 my $hash = XMLin($wsdl_file,ForceArray=>1,KeyAttr=>['xsd:element']);
77 use Data::Dumper qw(Dumper);
78 $Data::Dumper::Indent =3;
79 $Data::Dumper::Pair = " : ";
80 warn Dumper($hash);
81
82 }
83
84 =head1 AUTHOR
85
86 Linus, C<< <yuan_shijiang at 163.com> >>
87
88 =head1 BUGS
89
90 Please report any bugs or feature requests to C<bug-wsdl-xml-generator at rt.cpan.org>, or through
91 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WSDL-XML-Generator>. I will be notified, and then you'll
92 automatically be notified of progress on your bug as I make changes.
93
94
95
96
97 =head1 SUPPORT
98
99 You can find documentation for this module with the perldoc command.
100
101 perldoc WSDL::XML::Generator
102
103
104 You can also look for information at:
105
106 =over 4
107
108 =item * RT: CPAN's request tracker (report bugs here)
109
110 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=WSDL-XML-Generator>
111
112 =item * AnnoCPAN: Annotated CPAN documentation
113
114 L<http://annocpan.org/dist/WSDL-XML-Generator>
115
116 =item * CPAN Ratings
117
118 L<http://cpanratings.perl.org/d/WSDL-XML-Generator>
119
120 =item * Search CPAN
121
122 L<http://search.cpan.org/dist/WSDL-XML-Generator/>
123
124 =back
125
126
127 =head1 ACKNOWLEDGEMENTS
128
129
130 =head1 LICENSE AND COPYRIGHT
131
132 Copyright 2012 Linus.
133
134 This program is free software; you can redistribute it and/or modify it
135 under the terms of either: the GNU General Public License as published
136 by the Free Software Foundation; or the Artistic License.
137
138 See http://dev.perl.org/licenses/ for more information.
139
140
141 =cut
142
143 1; # End of WSDL::XML::Generator
↑ Summary