Quantcast
Channel: Adobe Community : Popular Discussions - ColdFusion
Viewing all articles
Browse latest Browse all 14291

How to handle Coldfusion SOAP Web Service Errors

$
0
0

Hi,

 

I have just created simple wsdl example:

My Component:

<cfcomponent displayname="mytest">

    <cffunction name="service_login_authentication" access="remote" output="true" returntype="any" hint="Returns login">
     <cfargument name="login" type="string" required="yes">
        <cfargument name="password" type="string" required="yes">

          <cfif #arguments.login# eq "abcdef" and #arguments.password# eq "123456">
                  <cfxml variable="soapRes">                
                        <kps_response>
                            <message>OK</message>
                            <token>354dfdffsdf</token>
                         </kps_response>

                    </cfxml>
             <cfelse>
                     <cfthrow type="MyException" message="INVALID LOGIN" errorcode="1000" />
         </cfif>        
 
      <cfreturn soapRes >
    </cffunction>
   
</cfcomponent>

 

Its generating wsdl and no problem with response but when generating any error like username and password does not match then it's generating fault code like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soapenv:Body>

      <soapenv:Fault>

         <faultcode>soapenv:Server.userException</faultcode>

         <faultstring>coldfusion.xml.rpc.CFCInvocationException: [coldfusion.runtime.CustomException : INVALID LOGIN. ]</faultstring>

         <detail>

            <ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">HOST_NAME</ns1:hostname>

         </detail>

      </soapenv:Fault>

   </soapenv:Body>

</soapenv:Envelope>

 

But I want customize Fault Code like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soapenv:Body>

      <soapenv:Fault>

         <faultcode>1000</faultcode>

         <faultstring>INVALID LOGIN</faultstring>

      </soapenv:Fault>

   </soapenv:Body>

</soapenv:Envelope>

 

Fault Code and Fault String should be customize and I don't want detail tag completely. In old ColdFusion version like ColdFusion 8 displaying detail tag with <ns1:stackTrace xmlns:ns1="http://xml.apache.org/axis/"> coldfusion.xml.rpc.CFCInvocationException: and so on.


Any suggestions on how to create customize faultcode and faultstring is very helpful.

 

Thanks!!

 



Viewing all articles
Browse latest Browse all 14291

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>