2011-08-08 27 views
8

这就是我认为是相关的SOAP ::精简版代码SOAP :: Lite生成<c-gensym ..>我该如何摆脱它?

my $req3 = SOAP::Lite->new(
    readable => 1, 
    autotype => 0, 
    proxy => 'https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor', 
); 

$req3->requestMessage(
    \SOAP::Data->new(
     name => 'item', 
     attr => { foo => '0' }, 
     value => \SOAP::Data->new(
      name => 'foo', 
      value => 1, 
     ), 
    ), 
); 

它生成此XML

<?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> 
    <c-gensym9> 
    <item foo="0"> 
     <foo>1</foo> 
    </item> 
    </c-gensym9> 
</requestMessage> 
</soap:Body> 

为什么<c-gensym9 />嵌套的<requestMessage>内我想不出但我不需要在那里。任何人都可以解释为什么它在那里?以及我如何重写代码,使其不是?

回答

2

看,不用gensym

$req3->requestMessage(
    ## \SOAP::Data->new(## this makes gensym 
    SOAP::Data->new(## no refref, no gensym 
     name => 'item', 
     attr => { foo => '0' }, 
     value => \SOAP::Data->new(
      name => 'foo', 
      value => 1, 
     ), 
    ), 
); 

又见http://perlmonks.com/?node_id=906383

0

不幸的是,我们真正需要帮助回答的代码是您(非常无意)排除为... # noisy SOAP::Data stuff的代码。

SOAP :: Lite可以相当gensym高兴。只要它不理解它试图生成的完整数据结构,它就会使用这个标签。因此,在您的示例中,定义requestMessage标记的SOAP :: Data对象似乎在不期望的情况下传递给数组,因此需要未命名(c-gensym5)中间标记。

鉴于上面生成的东西,看起来你可能试图传递一个散列[ { data } ]?每当SOAP :: Lite认为名称应该存在时(即[ no name for hash --> { data } ]),当没有提供名称时,它将“gensym”来澄清输出。这也可能是SOAP :: Lite期望某些内容不会被转义。

在soaplite.com非常官方的看职位,称为How do you turnoff the blasted c-gensym elements?不幸自己不是很有用(因为链接已经死了),但回机器可能会帮助。

我希望这会有所帮助。对不起,我不能更具体!

+0

是我发现后...不幸的是它的链接都死了...所以它也没用。 – xenoterracide

+0

@JT更新我的代码是一个完整的示例 – xenoterracide

+0

该文章中的链接可以在http://www.techrepublic.com/article/a-hands-on-tour-of-soaplite/1045078和http: //web.archive.org/web/20070308122644/http://www.majordojo.com/archives/2003_04.html – Ether

相关问题