SOAP :: Lite Web服务请求

时间:2014-04-22 23:13:28

标签: xml perl

我从一个有效的soap请求中获得了以下xml输出,我需要将其转换为perl。我通过添加参数成功创建了其他soap请求,但这是不同的,因为xml元素的属性为我创建了一个问题。这是请求。

<SendNotificationRequest clientIndicator="ISAAC_WFE" language="en" 
xsi:schemaLocation="http://edd.att.com/cnmeddservice EDD_Request.xsd"            xmlns="http://edd.att.com/cnmeddservice" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<ctype>TXT_TO_MGR</ctype> 
<ctn category="contact">917523xxxx</ctn> 
<data> 
<dataField name="MgrID">jz359m</dataField> 
<dataField name="SMSText">this is a test SMS message</dataField> 
</data> 
</SendNotificationRequest> 

这不起作用,我认为它是由于'category'和'name'字段是xml元素的属性,而不是元素本身。所以请告诉我这是否与我所需要的一致。

$self->{method_name} = 'SendNotificationRequest'; 
$self->{method_attr} = { 
  "clientIndicator" => 'ISAAC_WFE', 
  "language" => "en", 
  "xsi:schemaLocation" => 'http://edd.att.com/cnmeddservice EDD_Request.xsd', 
  "xmlns" => 'http://edd.att.com/cnmeddservice', 
  "xmlns:xsi" => 'http://www.w3.org/2001/XMLSchema-instance', 
  "xmlns:cnm" => 'http://edd.att.com/cnmeddservice', 
}; 

my $data = SOAP::Data->name($self->{method_name})->attr($self->{method_attr}); 
my @params = ( $data =>( 
SOAP::Data->type("")->name('ctype' => 'TXT_TO_MGR'), 
SOAP::Data->type("")->name('ctn')->attr({'category'})->value(SOAP::Data->value([ 
SOAP::Data->name('contact' => '917523xxxx')])), 
SOAP::Data->type("")->name(data => 
\SOAP::Data->type('')->value( 
SOAP::Data->type('')->name('dataField')->attr({'name'})->value(SOAP::Data->value([ 
SOAP::Data->name('MgrID' => 'jz359m')])), 
SOAP::Data->type('')->name('dataField')->attr({'name'})->value(SOAP::Data->value([ 
SOAP::Data->name('SMSText' => 'this is a test SMS message')])), 
)))); 
$self->{content} = $soap->call(@params); 
$self->{request} = $soap->serializer->envelope(method => $data, @params); 

1 个答案:

答案 0 :(得分:0)

来自Soap::Lite页面

print SOAP::Lite
  -> new(....)
    -> call(SOAP::Data->name('method')->attr({xmlns => 'mynamespace'})
        => @parameters)
    -> result;

所以你需要

SOAP::Data->name('ctn')->attr({category =>'contact' })
    ->value(SOAP::Data->value('917523xxxx'))

如果你可以发布一个SOAP网址,那么它将更容易提供帮助