简体   繁体   中英

How can I output the soap fragment with perl SOAP::Lite?

I am a new comer to soap protocol, so I want to find a perl module to produce soap fragments so that I can learn how to construct a soap fragment with it, SOAP::Lite is an excellent module for soap, but I can not find tutorials on how to output the soap fragment to files or stdout, so any tips?
regards.

use strictures;
use SOAP::Lite qw();
my $soap_body = SOAP::Data->name('foo' => \SOAP::Data->value(SOAP::Data->name('bar' => '123')));
print SOAP::Serializer->envelope(freeform => $soap_body);

$ perl -C /tmp/soap.pl | xmllint -format -
<?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" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <soap:Body>
    <foo>
      <bar xsi:type="xsd:int">123</bar>
    </foo>
  </soap:Body>
</soap:Envelope>

For experimentation tasks like this, it is usually better to use a REPL . It gives you quicker turn-around because you see the results immediately after entering an expression.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM