【问题标题】:SOAP::Lite Generating <c-gensym .. > how do I get rid of it?SOAP::Lite Generating <c-gensym ..> 我该如何摆脱它?
【发布时间】:2011-08-08 18:21:06
【问题描述】:

这是我认为相关的 SOAP::Lite 代码

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>

我不明白为什么&lt;c-gensym9 /&gt; 嵌套在&lt;requestMessage&gt; 内,但我不需要在那里。谁能解释它为什么在那里?以及如何重写代码以使其不是?

【问题讨论】:

    标签: xml perl soap


    【解决方案1】:

    你看,没有 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

    【讨论】:

    • 问题在于使用 Perl ref ``
    【解决方案2】:

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

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

    鉴于上面生成的内容,您似乎正在尝试传入一个带有哈希 [ { data } ] 的数组?每当 SOAP::Lite 认为应该存在名称(即[ no name for hash --&gt; { data } ])而没有提供任何名称时,它将“gensym”以澄清输出。也可能是 SOAP::Lite 期望转义某些未转义的内容。

    很遗憾,soaplite.com 上的一个非常官方的帖子 How do you turnoff the blasted c-gensym elements? 本身并没有太大帮助(因为链接已经失效),但返回机器可能会有所帮助。

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-07
    • 1970-01-01
    • 2020-12-25
    • 2013-03-20
    • 1970-01-01
    相关资源
    最近更新 更多