开发者

SOAP::Lite Generating <c-gensym .. > how do I get rid of it?

Here's what I believe to be the relevant SOAP::Lite code

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',
            valu开发者_如何转开发e => 1,
        ),
     ),
);

It's generating this 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>

I can't figure out why <c-gensym9 /> is nested inside of <requestMessage> but I need to not be there. Can anyone explain why it's there? and how I can rewrite the code so that it isn't?


Look ma, no 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,
        ),
     ),
);

see also http://perlmonks.com/?node_id=906383


Unfortunately, the code that we really need to help answer is the code you (quite unintentionally) excluded as ... # noisy SOAP::Data stuff.

SOAP::Lite can be pretty gensym happy. It uses this tag whenever it doesn't understand the full data structure that it's trying to generate. So in your example, the SOAP::Data object defining the requestMessage tag seems to get passed an array when one isn't expected, hence the need for an unnamed (c-gensym5) intermediary tag.

Given what's generated above, it seems you may be trying to pass in an array with a hash [ { data } ]? Whenever SOAP::Lite feels a name should be present (i.e. [ no name for hash --> { data } ]) when none is provided, it will "gensym" to clarify the output. It could also be that SOAP::Lite is expecting something to be escaped that isn't escaped.

A very official looking post over at soaplite.com called How do you turnoff the blasted c-gensym elements? is unfortunately not very helpful by itself (since the links out are dead) but the way back machine might be able to help.

I hope this helps. Sorry I can't be more specific!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜