I am trying to fake SOAP server functions for testing purposes. I use a the following code as a SOAP client:
SOAP return: use strict; use Data::Dumper; use SOAP::Lite + "trace"; my $soap = SOAP::Lite -> uri('http://www.perlmonks.org/FileQueue') -> proxy('http://localhost:88') ; my $rslt = $soap->getServerInfo()->result;
This generates the following output from the Real SOAP server:
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/env +elope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xm +lns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http:/ +/www.w3.org/1999/XMLSchema" xmlns:lwq="http://www.perlmonks.com/FileQ +ueue"> <SOAP-ENV:Body> <pmq:getServerInfoResponse> <info> <version>0.1.dev</version> <validTypes> <filetype>txt</filetype> <filetype>txt</filetype> </validTypes> <statistics> <documentsProcessed>0</documentsProcessed> </statistics> </info> </pmq:getServerInfoResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
Here is the code for the Fake SOAP Server:
use strict; use SOAP::Lite + "trace"; use SOAP::Transport::HTTP; use Data::Dumper; my $serverinfo = { version => "0.1.dev", validTypes => { filetype => "txt", filetype => "html", }, statistics => { documentsProcessed => 0, }, }; sub FileQueue::getServerInfo { return $serverinfo; } my $daemon = SOAP::Transport::HTTP::Daemon -> new (LocalPort => 88) -> dispatch_to('FileQueue') ; print "Contact to SOAP server at ", $daemon->url, "\n"; $daemon->handle;
This produces the following SOAP response:
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/env +elope/" xmlns:namesp2="http://xml.apache.org/xml-soap" xmlns:xsi="htt +p://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENC="http://schema +s.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/1999/XMLSc +hema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encodin +g/"> <SOAP-ENV:Body> <namesp3:getServerInfoResponse xmlns:namesp3="http://www.perlmonks +.org/FileQueue"> <s-gensym6 xsi:type="namesp2:SOAPStruct"> <statistics xsi:type="namesp2:SOAPStruct"> <documentsProcessed xsi:type="xsd:int">0</documentsProcessed +> </statistics> <version xsi:type="xsd:string">0.1.dev</version> <validTypes xsi:type="namesp2:SOAPStruct"> <filetype xsi:type="xsd:string">html</filetype> </validTypes> </s-gensym6> </namesp3:getServerInfoResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
How can I get precise control on the generated XML?

In the Real SOAP response, in the SOAP-ENV:Body, there is <pmq:getServerInfoResponse> node, how do I generate on in the Fake SOAP response?

In some of the XML code, there are xsi:type="xsd:string" values, how do I generate XML without it?

Any help would be appreciated;
-rppowell


In reply to SOAP::Transport::HTTP::Daemon and XML by rppowell

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.