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
Community Expert
Community Expert
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
Community Expert
Community Expert
November 25, 2014

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