我正在尝试向SOAP::Lite服务器发出请求,并且供应商希望我在MessageContent之前发送MessageSource的请求,但是当我将哈希传递给SOAP::Lite时,它总是会发送它反过来说。
我尝试使用Tie::IxHash无济于事。
我正在考虑用SOAP::Data->type('xml' => $xml_content)
手工编写XML,但它确实感觉像是一种解决方法会让支持变得非常烦人。
答案 0 :(得分:3)
我个人发现我更喜欢使用SOAP::Data::Builder
来构建SOAP :: Data,然后将其传递给SOAP :: Lite。
#!/usr/bin/perl
use 5.006;
use strict;
use warnings;
use SOAP::Lite +trace => [ 'debug' ];
use SOAP::Data::Builder;
my $req1 = SOAP::Lite->new(
readable => 1,
autotype => 0,
proxy => 'https://example.com/mysoapuri',
);
my $sb = SOAP::Data::Builder->new;
$sb->autotype(0);
$sb->add_elem(
name => 'clientLibrary',
value => 'foo',
);
$sb->add_elem(
name => 'clientLibraryVersion',
value => 'bar',
);
$sb->add_elem(
name => 'clientEnvironment',
value => 'baz',
);
my $ret = $req1->requestMessage( $sb->to_soap_data );
这将生成以下SOAP
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<requestMessage>
<clientLibrary>foo</clientLibrary>
<clientLibraryVersion>bar</clientLibraryVersion>
<clientEnvironment>baz</clientEnvironment>
</requestMessage>
</soap:Body>
</soap:Envelope>
注意:我意识到添加另一个依赖项可能不在卡片中...不幸的是,我从未真正弄清楚如何才能正确获取数据。