Client.pm untested

filter: Statementstmt 0.0% 0 / 57 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 108 CC 6 SCAR 20.0
CC
6
Cov
0%
send_receive
20.0
publish
12.0
BEGIN
2.0
CRAP 7.4
1 package SOAP::Client;
2 use base qw ( Aw::Client );
3  
4  
5 BEGIN
6 {
7 use SOAP::Transport::ActiveWorks::Defs;
8 }
9  
10 sub publish
11 {
12 my ($self, $request) = @_ ;
13  
14  
15 my $event = undef;
16 $event = ( $self->SUPER::publish ( $request ) )
17 ? undef
18 : $self->getEvent ( $AW_REQUEST_TIMEOUT );
19  
20 return ( {errorText => "NullReply"} ) if ( !$event || $event->isNullReply );
21  
22 my %hash = $event->toHash;
23 $event->delete;
24 $event = undef;
25  
26 \%hash;
27 }
28  
29  
30  
31 package SOAP::Transport::ActiveWorks::Client;
32  
33  
34 BEGIN
35 {
36 use strict;
37 use vars qw($VERSION $ua $post);
38 $VERSION = '0.10';
39  
40 use SOAP::Defs;
41 use Carp;
42  
43 require Aw::Event;
44 }
45  
46  
47 sub new {
48 my ($class) = @_;
49  
50 my $self = {
51 debug_request => 0,
52 };
53 bless $self, $class;
54  
55 $self;
56 }
57  
58 sub debug_request {
59 my ($self) = @_;
60 $self->{debug_request} = 1;
61 }
62  
63  
64 #
65 # keep args in sync with HTTP for now
66 #
67 sub send_receive {
68 my ($self, $host, $port, $broker, $client_group, $request_class, $method_uri, $method_name, $soap_request) = @_;
69  
70 $port = 6849 unless(defined($port) and $port);
71
72 $ua ||= new SOAP::Client ( "$host:$port", $broker, "", $client_group, "SOAP::Client" );
73 $post ||= new Aw::Event ( $ua, "SOAP::Request");
74 $post->setField ( envelope => $soap_request );
75  
76 #
77 # NOTE NOTE NOTE
78 # CLR prefers a semicolon here
79 # clearly this needs some fixing - maybe allow client to specify SOAPAction directly?
80 #
81 $post->setField ( SOAPClass => $request_class );
82 $post->setField ( SOAPAction => $method_uri . '#' . $method_name );
83  
84 if ($self->{debug_request}) {
85 $post->setField('DebugRequest' => '1');
86 }
87  
88 #
89 # TBD: content-length isn't taking into consideration CRLF translation
90 #
91 $post->setField (Content_Type => 'text/xml');
92 $post->setField (Content_Length => length($soap_request));
93
94 my $aw_response = $ua->publish ( $post );
95  
96 # my $code = $http_response->code();
97 my $content;
98  
99  
100 #
101 # Check for Aw Errors
102 #
103 if ( $aw_response->{errorText} ) {
104 $content = $self->_output_soap_fault(0,
105 'Application Faulted',
106 "An exception fired while processing the request: $aw_response->{errorText}",
107 # $response_header_writer, $response_content_writer);
108 );
109 }
110 else {
111 $content = $aw_response->{envelope};
112 }
113  
114  
115 $content;
116 }
117  
118  
119  
120 sub _output_soap_fault {
121 my ($self, $faultcode, $faultstring, $result_desc,
122 $response_header_writer, $response_content_writer) = @_;
123  
124 my $response_content = qq[<s:Envelope xmlns:s="$soap_namespace"><s:Body><s:Fault><faultcode>s:$faultcode</faultcode><faultstring>$faultstring</faultstring><detail>$result_desc</detail></s:Fault></s:Body></s:Envelope>];
125  
126 #
127 # skip these for now
128 #
129 # my $response_content_length = length $response_content;
130  
131 # $response_header_writer->('Content-Type', 'text/xml');
132 # $response_header_writer->('Content-Length', $response_content_length);
133 # $response_content_writer->($response_content);
134 }
135  
136  
137 1;
138 __END__