Skip to main content
HaroonTyagi
Known Participant
Nov 24, 2014 1:41 PM UTC
Question

How to get Soap Request xml in application.cfc

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 is closed to new replies. Start a new post to keep the conversation going.

15 replies

BKBK
Community Expert
Community Expert
Nov 25, 2014 12:15 PM UTC

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.

Translate
HaroonTyagi
Known Participant
Nov 25, 2014 12:51 PM UTC

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!

Translate
BKBK
Community Expert
Community Expert
Nov 25, 2014 2:54 PM UTC

What you show (mydata) is just an XML variable. It is not  a SOAP request. A SOAP request is, for example, a CFC method whose access is 'remote'.

Translate