• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to handle Coldfusion SOAP Web Service Errors

New Here ,
Oct 19, 2014 Oct 19, 2014

Copy link to clipboard

Copied

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!!


TOPICS
Advanced techniques

Views

3.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 20, 2014 Oct 20, 2014

Copy link to clipboard

Copied

A suggestion:

<cfset var isLoginValid = False>

<cftry>

    <!--- Your code for testing login --->

    <cfif arguments.login eq "abcdef" and arguments.password eq "123456">

        <cfset isLoginValid = True>

    </cfif>

    <cfif isLoginValid>

        <cfxml variable="soapRes">

           <kps_response>

               <message>OK</message>

               <token>354dfdffsdf</token>

            </kps_response>

         </cfxml>

    <cfelse>

        <cfthrow type="MyException" message="INVALID LOGIN" errorcode="1000" />

    </cfif>

<cfcatch type="MyException">

    <cfxml variable="soapRes">

        <kps_response>

        <cfoutput><faultcode>#cfcatch.errorCode#</faultcode>

        <faultstring>#cfcatch.message#</faultstring></cfoutput>

        </kps_response>

    </cfxml>

</cfcatch>

</cftry>

<cfreturn soapRes>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 21, 2014 Oct 21, 2014

Copy link to clipboard

Copied

Thanks BKBK

I have tested in this way but in this case its generating fault code inside a response 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>

     <ns1:service_soap_loginResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://DefaultNamespace">

         <service_soap_loginReturn xsi:type="ns2:Document" xmlns:ns2="http://xml.apache.org/xml-soap">

            <kps_response>

               <faultcode>1000</faultcode>

               <faultstring>Invalid</faultstring>

             <kps_response>

         </service_soap_loginReturn>

      </ns1:service_soap_loginResponse>

   </soapenv:Body>

</soapenv:Envelope>

I want that Fault code should be inside Soap:Fault 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_PASSWORD</faultstring>

      </soapenv:Fault>

   </soapenv:Body>

</soapenv:Envelope>

Any ideas?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 21, 2014 Oct 21, 2014

Copy link to clipboard

Copied

My suggestion just followed your example, presuming it works and expecting you to fill in the details. If I had to do it myself, I would:

- make the code more universal by using <cfsavecontent> in place of <cfxml> and returning string type.

- set the output attribute to false.

Something like this:

<cfcomponent output="false">

<cffunction name="service_login_authentication" access="remote" output="false" returntype="string" hint="Returns login">

<cfargument name="login" type="string" required="yes">

<cfargument name="password" type="string" required="yes">

<cfset var isLoginValid = False>

<cftry>

    <!--- Your code for testing login --->

    <cfif arguments.login eq "abcdef" and arguments.password eq "123456">

        <cfset isLoginValid = True>

    </cfif>

    <cfif isLoginValid>

        <cfsavecontent variable="soapRes"><?xml version="1.0" encoding="UTF-8"?>

           <kps_response>

               <message>OK</message>

               <token>354dfdffsdf</token>

            </kps_response>

         </cfsavecontent>

    <cfelse>

        <cfthrow type="MyException" message="INVALID LOGIN" errorcode="1000" />

    </cfif>

<cfcatch type="MyException">

    <cfsavecontent variable="soapRes">

    <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>

             <<cfoutput><faultcode>#cfcatch.errorCode#</faultcode>

                       <faultstring>#cfcatch.message#</faultstring></cfoutput>

          </soapenv:Fault>

       </soapenv:Body>

    </soapenv:Envelope

    </cfsavecontent>

</cfcatch>

</cftry>

<cfreturn soapRes>

</cffunction>

</cfcomponent>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 21, 2014 Oct 21, 2014

Copy link to clipboard

Copied

Many Thanks BKBK!!

I already check this. When calling GetSOAPResponse it just take the whole cfsavecontent string inside response 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>

      <ns1:service_soap_loginResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://wsdl.research">

        <service_soap_loginReturn xsi:type="xsd:string">

<![CDATA[<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>]]>

</service_soap_loginReturn>

      </ns1:service_soap_loginResponse>

   </soapenv:Body>

</soapenv:Envelope>

Any ideas?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 21, 2014 Oct 21, 2014

Copy link to clipboard

Copied

HaroonTyagi wrote:

I already check this.

...

...

Any ideas?

I don't understand what you mean. Are you asking a new question? Did my last suggestion work or not?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 21, 2014 Oct 21, 2014

Copy link to clipboard

Copied

I am saying that your last suggestion I have checked but not working.

From your last suggestion the output of fault is :

<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>

      <ns1:service_soap_loginResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://wsdl.research">

        <service_soap_loginReturn xsi:type="xsd:string">

<![CDATA[<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>]]>

</service_soap_loginReturn>

      </ns1:service_soap_loginResponse>

   </soapenv:Body>

</soapenv:Envelope>

But the output should be as below:

<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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 21, 2014 Oct 21, 2014

Copy link to clipboard

Copied

The component you are using as web service is probably different from mine.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 21, 2014 Oct 21, 2014

Copy link to clipboard

Copied

I am using same component which you given:

<cfcomponent output="false">

<cffunction name="service_login_authentication" access="remote" output="false" returntype="string" hint="Returns login">

<cfargument name="login" type="string" required="yes">

<cfargument name="password" type="string" required="yes">

<cfset var isLoginValid = False>

<cftry>

    <!--- Your code for testing login --->

    <cfif arguments.login eq "abcdef" and arguments.password eq "123456">

        <cfset isLoginValid = True>

    </cfif>

    <cfif isLoginValid>

        <cfsavecontent variable="soapRes"><?xml version="1.0" encoding="UTF-8"?>

           <kps_response>

               <message>OK</message>

               <token>354dfdffsdf</token>

            </kps_response>

         </cfsavecontent>

    <cfelse>

        <cfthrow type="MyException" message="INVALID LOGIN" errorcode="1000" />

    </cfif>

<cfcatch type="MyException">

    <cfsavecontent variable="soapRes">

    <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>

             <<cfoutput><faultcode>#cfcatch.errorCode#</faultcode>

                       <faultstring>#cfcatch.message#</faultstring></cfoutput>

          </soapenv:Fault>

       </soapenv:Body>

    </soapenv:Envelope>

    </cfsavecontent>

</cfcatch>

</cftry>

<cfreturn soapRes>

</cffunction>

</cfcomponent>

I did not change anything. if you have another component can you post here so I can check if I am doing something wrong may be.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 21, 2014 Oct 21, 2014

Copy link to clipboard

Copied

Your code might be invoking a cached, hence old, version of the WSDL. Do something like the following to make sure the current WSDL is invoked:

<cfset argStruct.refreshWSDL="yes">

<cfset ws=createobject("webservice","http://127.0.0.1:8500/workspace/myServices/soapTest.cfc?wsdl",argStruct)>

<cfdump var="#ws.service_login_authentication('abc','123456')#">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 21, 2014 Oct 21, 2014

Copy link to clipboard

Copied

thanks BKBK, it's working.

I was calling like this:

<cfscript>

ws = CreateObject("webservice","http://localhost/CFTest/MainLogin.cfc?wsdl", {refreshWSDL=true});

ws.service_login_authentication("1111","1111");

req = GetSOAPResponse(ws);

writeoutput(req);

</cfscript>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 22, 2014 Oct 22, 2014

Copy link to clipboard

Copied

It is possible I can get this fault output from GetSOAPResponse(webservice)  because I just want to pass from CFC main fault code and main response, I don't want to pass complete soap xml.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 22, 2014 Oct 22, 2014

Copy link to clipboard

Copied

I would strive to keep the web service as simple and as universal as possible. That often means passing and returning simple types.

This is especially relevant because Coldfusion is weakly typed. What it calls 'any' or 'xml' type may be interpreted quite differently by other platforms. That is what my suggestion has been all about.

You should either accept what Coldfusion's GetSOAPResponse(webservice) is giving you or you should craft the SOAP response you want, as I did in my suggestion, and return it as a string.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 01, 2014 Dec 01, 2014

Copy link to clipboard

Copied

Dear All Technology Expert's,

I have a query related to Coldfusion SOAP services, that is most commonly asked in all the forum's but NONE of them has got answer.

If there is NO solution so I think Adobe has to come up with some patches so developer can able to do some customization.

I like to share with you all, in all other language ( PHP, JAVA, .NET etc) this option is available and you can customize the error.

Ok let me again explain the very basic error:

SOAP Request:

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

   <soapenv:Header/>

   <soapenv:Body>

    

   </soapenv:Body>

</soapenv:Envelope>

SOAP Response:

  <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>java.lang.Exception: Body not found.</faultstring>

         <detail>

            <ns1:stackTrace xmlns:ns1="http://xml.apache.org/axis/">java.lang.Exception: Body not found.

  at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:121)...</ns1:stackTrace>

            <ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">Coldfusion Error</ns2:hostname>

         </detail>

      </soapenv:Fault>

   </soapenv:Body>

</soapenv:Envelope>

HOW we can customize the error, in all other languages you can simple customize the error like

Other languages SOAP response:

  <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>BODY_NOT_FOUND</faultcode>

         <faultstring>Body is missing in your request</faultstring>

        

      </soapenv:Fault>

   </soapenv:Body>

</soapenv:Envelope>

But the same is NOT possible in Coldfusion, right?

AS you know it is vulnerability to display exception messages in the response.

We are developing this web service to access  from other language website (PHP, .NET).

We are also planning to upgrade server the Coldfusion 11, but do you think there is any solution with latest Coldfusion version.

Please response only if you know about these issue's or solution. 

Thanks

Niyaz

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 01, 2014 Dec 01, 2014

Copy link to clipboard

Copied

@Niyaz

You will gain little by asking the same question in multiple places in the forum. In fact, it could be considered as spamming.

This question is being discussed in the thread that HaroonTyagi started. (Are you HaroonTyagi?) I will post an answer there shortly.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 01, 2014 Dec 01, 2014

Copy link to clipboard

Copied

Hi Thanks for the response, I want a  proper response so try to post as much as possible it's not SPAM. The purpose was to reach more people some one can have answer better than others.

I am trying to contact adobe also on the same but no luck.

Thanks

Niyaz

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 01, 2014 Dec 01, 2014

Copy link to clipboard

Copied

@HaroonTyagi, @Niyaz

I am now able to make time so that we can explore this question in full. First of all, let us get some assumptions and misconceptions out of the way.

For example, HaroonTyagi insisted that one should be able to throw and handle a custom exception when invoking a web service using cfhttp. This expectation may have a basis in the client-server model, where methods are explicitly invoked, but it has no basis here.

In fact, Adobe ColdFusion owes you no explanation about the use of cfhttp to invoke SOAP web services. Neither can it guarantee anything about this usage. The reason is that, using the post method of cfhttp to invoke web services is an undocumented method. By this, I mean that, although creative developers have discovered that it can be so used, it was not designed for that purpose.

The officially documented native Coldfusion ways to consume a web service are by means of <cfobject>, <cfinvoke> and createobject(), or their various script/tag equivalents. There is one big difference between these functionalities and <cfhttp method="post">. If the web service has a compulsory method, then they must call it. Neither <cfobject>, <cfinvoke> nor createobject() can intereact with a web service without explicitly calling its methods.

That is in keeping with the principles of the client-server model of computing. In this case, the web service is the server and the calling application the client. The client makes a request to the service by invoking its method; the server responds by means of a method return.

In contrast, a client using <cfhttp method="post"> may interact with a web service without calling its methods. For example, by posting a SOAP message containing a blank body to the service, as HaroonTyagi has done. In that case, you should not expect to be able to apply client-server validation methods, as these necessarily require that methods be explicitly called. In fact, in the client-server model, the method or function is the web service proper.

Therefore, you should perform custom validation in your CFC with the assumption that the service will be consumed by means of <cfobject>, <cfinvoke> or createobject(). There is a further advantage of assuming these will be used, instead of <cfhttp method="post">. The calls based on <cfobject>, <cfinvoke> and createobject() are the Coldfusion equivalents of calls that will be made from other languages, like PHP, .NET, and so on.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 03, 2014 Dec 03, 2014

Copy link to clipboard

Copied

thanks BKBK,

According to you, The officially documented native Coldfusion ways to consume a web service are by means of <cfobject>, <cfinvoke> and createobject(), or their various script/tag equivalents.

As of you, should be used <cfobject>, <cfinvoke> and createobject() these methods right. But do you think all client side technology will be in ColdFusion and if not then we don't know how the clients calling from another technology.

Now my question, if I have developed my webservice in Coldfusion technology but if client accessing from different technology like php, .NET or any other soap supported technology or may be just use SoapUI software tool.

In this case how can customize every single type exception, I never want to display auto generated exception code to clients.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2014 Dec 04, 2014

Copy link to clipboard

Copied

LATEST

Hi HaroonTyagi,

I have already answered your question.

HaroonTyagi wrote:

As of you, should be used <cfobject>, <cfinvoke> and createobject() these methods right. But do you think all client side technology will be in ColdFusion and if not then we don't know how the clients calling from another technology.

I do not assume all client side technology will be Coldfusion. I said,

The calls based on <cfobject>, <cfinvoke> and createobject() are the Coldfusion equivalents of calls that will be made from other languages, like PHP, .NET, and so on.

Unlike cfhttp-post, calls from <cfobject>, <cfinvoke> and createobject() force the client to invoke the web service's method. Similarly, calls from PHP, .NET or SOAPUI will also invoke the method. That in turn enables the service to perform custom validation.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 21, 2014 Oct 21, 2014

Copy link to clipboard

Copied

HaroonTyagi wrote:

I am saying that your last suggestion I have checked but not working.

But the output should be as below:

<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>

This is exactly the result that my suggestion produces. I have just checked it myself.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 21, 2014 Oct 21, 2014

Copy link to clipboard

Copied

But my component is not produces this fault code:

<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>


What is your ColdFusion Version as i have checked in ColdFusion 11 developer edition and ColdFusion 8 enterprise which is on window 2003 server.

Could you please check my below component, did i am doing something wrong.

<cfcomponent output="false">

    <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">
  <cfset var isLoginValid = False>
        <cftry>
          <cfif #arguments.login# eq "1111" and #arguments.password# eq "1111">
              <cfset isLoginValid = True>
            </cfif>
           
             <cfif isLoginValid>
                    <cfsavecontent variable="soapRes"><?xml version="1.0" encoding="UTF-8"?>           
                       <kps_response>           
                           <message>OK</message>           
                           <token>354dfdffsdf</token>           
                        </kps_response>           
                     </cfsavecontent>           
                <cfelse>           
                    <cfthrow type="MyException" message="INVALID LOGIN" errorcode="1000" />           
                </cfif>
               
                  <cfcatch type="MyException">           
                     <cfsavecontent variable="soapRes">               
                            <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>                   
                                     <<cfoutput><faultcode>#cfcatch.errorCode#</faultcode>                   
                                               <faultstring>#cfcatch.message#</faultstring></cfoutput>                   
                                  </soapenv:Fault>                   
                               </soapenv:Body>                   
                            </soapenv:Envelope>                  
                       </cfsavecontent>
               
                </cfcatch>
           
            
           
            </cftry>     
      <cfreturn soapRes >
    </cffunction>
  
</cfcomponent>

If my component is okay then may be possible some setting in ColdFusion administrator. i have checked in SoapUI as well via getSoapResponse method.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation