[ic] split or \$myvar is not parsing or interpolte in a right way
jojospace
info at ebusiness-leidinger.de
Sun Dec 7 16:06:23 UTC 2008
Peter wrote:
> On 12/06/2008 09:10 AM, jojospace wrote:
>> And why ist
>>
>> sub array_string {
>> my ($name, @data) = @_;
>> my $soap_data = SOAP::Data->value(SOAP::Data->name("string" =>
>> @data)->type(""));
>> $soap_data->type('ArrayOfString');
>> return SOAP::Data->name($name, \$soap_data);
>> }
>>
>> not working like a normal perl script? \$soap_data make me mad!
>
> First you're not giving anyone enough info to go on here. What is this
> sub supposed to do? What error messages does it produce (check the logs)?
>
> Secondly, I'm not a SOAP expert by any stretch.
>
> Third, you are trying to pass an array on the right side of a =>
> construct, which is designed to accept a scalar, it probably won't do
> whatever you think it will do (which I still don't quite understand).
>
> It boils down to ... it just doesn't look right to me and I don't know
> what you are trying to do so I can't tell you how to fix it properly.
>
> Peter
Hi Peter,
here is the full perl script myscript.pl:
#!/usr/bin/perl
use Data::Dump qw(dump);
use SOAP::Lite trace => 'all';
use constant SERIENNUMMER => 'test';
use constant PASSWORT => 'test';
my ($rv, $retObj) = &sendsms("Testmessage","2008-11-26T12:00:33",
"Standard","Absender",split("\n","0049171123456789\n0049171987654321"));
print "$rv: $rv \nLoginStatusCode:" . $retObj->{"StatusCode"} ."
\nAnnahmeStatus:" . $retObj->{"Value"}->{"Status"} . " \nJobId: " .
$retObj->{"Value"}->{"JobId"} . "\n";
exit;
use constant URI => 'http://www.xyz.com/gateway';
sub sendsms
{
my ($msg, $schedule, $smsType,$sender, at clis) = @_;
$msg = substr($msg, 0, 160);
my $soap = SOAP::Lite
-> uri(URI)
-> proxy('http://www.xyz.com/gateway/Send.asmx')
-> encoding('utf-8')
-> on_action(sub{sprintf '%s/%s', @_ })
;
my $User = SOAP::Data->name('User' => SERIENNUMMER)->type('');
my $Pw = SOAP::Data->name('Password' => PASSWORT)->type('');
my $Caption = SOAP::Data->name('Caption' => "Caption")->type('');
my $Sender = SOAP::Data->name('Sender' => "$sender")->type('');
my $Empf = array_string("Recipient", @clis);
my $Text = SOAP::Data->name('SMSText' => "$msg")->type('');
my $SMSTyp = SOAP::Data->name('SmsTyp' => "$smsType")->type('');
my $SendDate = SOAP::Data->name('SendDate' => "$schedule")->type('');
my $result = $soap->call (SOAP::Data->name ('SendSMS')->attr ({xmlns
=> URI}),
($User,$Pw, $Caption, $Sender,$Empf, $Text, $SMSTyp, $SendDate));
unless ($result->fault)
{
my $rv = $result->result();
return(0,$rv);
}
else
{
my $str = join ', ',
$result->faultcode,
$result->faultstring,
$result->faultdetail;
return(-1, $str);
}
}
sub array_string {
my ($name, @data) = @_;
my $soap_data = SOAP::Data->value(SOAP::Data->name("string" =>
@data)->type(""));
$soap_data->type('ArrayOfString');
# this is my problems
return SOAP::Data->name($name, \$soap_data);
}
The result is
<SendSMS xmlns="http://www.xyz.com/gateway">
<User>string</User>
<Password>string</Password>
<Caption>string</Caption>
<Sender>string</Sender>
<Recipient>
<string>string</string>
<string>string</string>
</Recipient>
<SMSText>string</SMSText>
<SmsTyp>Standard</SmsTyp>
<SendDate>dateTime</SendDate>
</SendSMS>
But in a usertag or perl tag, i get
<SendSMS xmlns="http://www.xyz.com/gateway">
<User>string</User>
<Password>string</Password>
<Caption>string</Caption>
<Sender>string</Sender>
<string>string</string>
<string>string</string>
<SMSText>string</SMSText>
<SmsTyp>Standard</SmsTyp>
<SendDate>dateTime</SendDate>
</SendSMS>
there is a missing <Reicpient></Recipient>
If i use
my $Empf = array_string("Recipient", @clis);
instead of
my $Empf = array_string("Recipient",
"<string>111</string><string>222</string>")->type("");
I can create a workaround. But I want to know, why is the behavior of
this perl script not the same in a usertag? Why is \$soap_data a problem
in a usertag?
Thank you for your helps!
Joachim
More information about the interchange-users
mailing list