http://qs1969.pair.com?node_id=1119550

ghenry has asked for the wisdom of the Perl Monks concerning the following question:

Dear all,

I'm trying to debug this method https://github.com/simoncozens/Net-KashFlow/blob/master/lib/Net/KashFlow.pm#L559

sub email { my ($self, $data) = @_; $data->{InvoiceNumber} = $self->{InvoiceNumber}; for (qw/FromEmail FromName SubjectLine Body RecipientEmail/) { die "You must supply the $_ parameter" unless $data->{$_}; } $self->{kf}->_c("EmailInvoice", $data); }

but can't work out why it is producing broken XML due to the InvoiceNumber closing round everything:

<?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" +xmlns:s1="KashFlow/AbstractTypes" xmlns:soapenc="http://schemas.xmlso +ap.org/soap/encoding/" xmlns:tns="KashFlow" xmlns:xsd="http://www.w3. +org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-insta +nce" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <soap:Body> <EmailInvoice xmlns="KashFlow"> <UserName xsi:type="xsd:string">my_user</UserName> <Password xsi:type="xsd:string">my_pass</Password> <InvoiceNumber xsi:type="xsd:int"> <FromName xsi:type="xsd:string">Billing</FromName> <FromEmail xsi:type="xsd:string">billing@billing.co.uk</Fr +omEmail> <RecipientEmail xsi:type="xsd:string">ghenry@ghenry.co.uk< +/RecipientEmail> <Body xsi:type="xsd:string">Many thanks for your business! Please see attached invoice. -- Kind Regards, Billing. E billing@billing.co.uk http://www.billing.co.uk</Body> <InvoiceNumber xsi:type="xsd:int">239925</InvoiceNumber> <SubjectLine xsi:type="xsd:string">Invoice from billing fo +r February 2015</SubjectLine> </InvoiceNumber> </EmailInvoice> </soap:Body> </soap:Envelope>

code in https://github.com/simoncozens/Net-KashFlow/blob/master/lib/Net/KashFlowAPI.pm#L20 is:

EmailInvoice => { endpoint => 'https://securedwebapp.com/api/service.asmx', soapaction => 'KashFlow/EmailInvoice', namespace => 'KashFlow', parameters => [ SOAP::Data->new(name => 'UserName', type => 'xsd:string', attr = +> {}), SOAP::Data->new(name => 'Password', type => 'xsd:string', attr = +> {}), SOAP::Data->new(name => 'InvoiceNumber', type => 'xsd:int', attr + => {}), SOAP::Data->new(name => 'FromEmail', type => 'xsd:string', attr +=> {}), SOAP::Data->new(name => 'FromName', type => 'xsd:string', attr = +> {}), SOAP::Data->new(name => 'SubjectLine', type => 'xsd:string', att +r => {}), SOAP::Data->new(name => 'Body', type => 'xsd:string', attr => {} +), SOAP::Data->new(name => 'RecipientEmail', type => 'xsd:string', +attr => {}), ], # end parameters }, # end EmailInvoice

called using https://github.com/simoncozens/Net-KashFlow/blob/master/lib/Net/KashFlow.pm#L50:

sub _c { my ($self, $method, @args) = @_; my ($result, $status, $explanation) = KashFlowAPI->$method($self->{username}, $self->{password}, @ar +gs); if ($explanation) { croak($explanation) } return $result; }

The data being passed to $self->{kf}->_c("EmailInvoice", $data) via $invoice->email() is:

$VAR1 = { 'FromName' => 'Billing', 'FromEmail' => 'billing@billing.co.uk', 'RecipientEmail' => 'ghenry@ghenry.co.uk', 'Body' => 'Many thanks for your business! Please see attached invoice. -- Kind Regards, Billing. E billing@billing.co.uk http://www.billing.co.uk', 'InvoiceNumber' => '239925', 'SubjectLine' => 'Invoice from Billing for February 2015' };

Any ideas how to trace this double InvoiceNumber getting opened and closed around the actual passed in data?