Kind Monks,

I'm building a SOAP interface using XML::Compile::SOAP::HTTPDaemon module (version 2.02). The communication protocol is defined by WSDL files. There also exists a reference implementation of the server.

I got the HTTPDaemon running, I've loaded the WSDL definitions, and created a callback function for one of the defined operations. I'm also able to give a proper response for a proper request. WSDL definition of the operation follows:

<wsdl:operation name="sendSms"> <wsdl:input message="parlayx_sms_send:SendSms_sendSmsRequest"/> <wsdl:output message="parlayx_sms_send:SendSms_sendSmsResponse"/> <wsdl:fault name="ServiceException" message="parlayx_common_faults:S +erviceException"/> <wsdl:fault name="PolicyException" message="parlayx_common_faults:Po +licyException"/> </wsdl:operation>

The problem comes when something is wrong in the request and I want to throw an exception (return a fault response in SOAP terms). The reference server returns (e.g.) a message like this:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <soap:Fault> <faultcode>soap:Server</faultcode> <faultstring>Policy exception</faultstring> <detail> <ns3:PolicyException xmlns:ns2="http://www.csapi.org/schema/parlay +x/sms/send/v3_1/local" xmlns:ns3="http://www.csapi.org/schema/parlayx +/common/v3_1"> <messageId>POL0001</messageId> <text>A policy error occurred. Error code is POL-008: TPA is inv +alid.</text> <variables>POL-008</variables> <variables>TPA is invalid.</variables> </ns3:PolicyException> </detail> </soap:Fault> </soap:Body> </soap:Envelope>

I'm unable to get this kind of XML out of nested hash structure returned from the callback function. I tried this...:

return +{ Fault => { detail => { PolicyException => { messageId => $error_code, text => $error_message, variables => [ $error_code, $error_message, ], } }, faultcode => pack_type('SOAP-ENV', 'Server'), faultstring => 'Policy exception', }, };

...but this leads to empty detail element in the response:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/env +elope/"> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:Server</faultcode> <faultstring>Policy exception</faultstring> <detail/> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

I also tried to create the PolicyException element (same as in the reference response) by myself using XML::LibXML and asigning it to the 'detail' key directly, but then I get this error message:

warning: Answer included error: element `{http://www.csapi.org/schema/parlayx/common/v3_1}Polic +yException' not processed at {http://schemas.xmlsoap.org/soap/envelop +e/}Fault

Kind Monks, could please give me some good advice?


In reply to returning Fault response in XML::Compile::SOAP::HTTPDaemon by buff

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.