Skip to main content
Participating Frequently
April 5, 2013
Question

Return Soap Fault in CF web service

  • April 5, 2013
  • 1 reply
  • 889 views

How do I return a Soap Fault like this:

      <soapenv:Fault>

         <faultcode>soapenv:Client.Validation</faultcode>

         <faultstring>SalesCode must be 5 characters in length</faultstring>

        ...

      </soapenv:Fault>

instead of a CFCInvocationException?

    This topic has been closed for replies.

    1 reply

    Inspiring
    November 14, 2013

    Hi Dina,

    Did you find a solution to your problem? I'm looking at doing the same thing.

    Cheers,
    Simon

    Dina HessAuthor
    Participating Frequently
    November 17, 2013

    I had to use a workaround. In the complex type (CFC) returned by the web

    service, I added two additional properties, success (boolean) and fault

    (string). That way, if validation fails, I set success to false and return

    validation messages in the fault property using syntax like this:

    . It communicates what the client needs to know but

    is not in the format I originally wanted to implement. I did find a clue

    about how to get control of the SOAP envelope in a comment made by Arthur

    Blake at the end of one of Ben Nadel's blog entries about using HTTP to

    consume a web service. He said he could customize the XML request/response by

    writing a "proxy" in ColdFusion that forwards to the real SOAP service. I

    never did figure out how to go about doing that, so if you happen to get

    your head around it, please post your solution. In general, I found that

    ColdFusion 8 doesn't play nicely with a pre-defined complex WSDL that

    import XSDs and doesn't honor a "required=no" setting in the property tag

    of a complex type's CFC when generating its WSDL dynamically. In fact, I

    have a whole list of "gotchas" on this... Didn't mean to write a book, but

    you opened an old wound that had just about healed. Good luck, Simon. Hope

    I didn't douse too much water on your passion to move forward with this.