Skip to main content
HaroonTyagi
Known Participant
November 24, 2014
Question

How to get Soap Request xml in application.cfc

  • November 24, 2014
  • 1 reply
  • 3253 views

Hi

if api getting soap request using cfhttp like below:

<cfxml variable="mydata">

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

   <soapenv:Header />

   <soapenv:Body>

       <ns:service_soap_call soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

        <login>test</login>

        <password>test</password>

      </ns:service_soap_call>

   </soapenv:Body>

</soapenv:Envelope>

</cfxml>

 

  <cfhttp url="http://sm.iclp-dubai.ae/research/wsdl/MyPointsBank.cfc?wsdl" method="post" charset="utf-8" result="myresult">

       type" value="text/xml">

        <cfhttpparam type="header" name="SOAPAction" value="">

       <cfhttpparam name="soapInput" type="xml" value="#trim(mydata)#"/>

</cfhttp>

then how to get Soap Request in application cfc.

like :

<cfif IsSOAPRequest() >

  <cfset soapreq = GetSOAPRequest() />

</cfif>

I want to validate the soap xml Request before calling targeted CFC.

Any suggestion!.

This topic has been closed for replies.

1 reply

BKBK
Braniac
November 25, 2014

Why would you want to do that in Application.cfc? The whole idea behind the design of IsSOAPRequest() is that it is to be used within a CFC to indicate when the CFC is called as a web service. In your case, it would be appropriate to put it in MyPointsBank.cfc instead.

HaroonTyagi
Known Participant
November 25, 2014

Thanks BKBK,

I want to validate soap request before calling the targeted CFC method.
Consider this example if the soap request without the method body like below:

<cfxml variable="mydata">

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

   <soapenv:Header />

   <soapenv:Body>

      

   </soapenv:Body>

</soapenv:Envelope>

</cfxml>

then how to validate this and display proper fault code. In this case coldfusion generating a below exception:

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

but I wan to display proper fault code.

Any Idea!

BKBK
Braniac
November 26, 2014

BKBK, You know very well all soap request directly calling CFC Component, right

If this is my CFC component then could you explain me please where I will check the soap body and how

<cfcomponent output="no">

<cffunction name="service_soap_call" access="remote" output="no" returntype="any" >

      <cfargument name="argument1">

     ................................    

</cfcomponent>


In the function, of course. You can tell from the use of 'var', 'arguments' and 'cfreturn'.