• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Working with SOAP Requests

ColdFusion offers a variety of ways to work with the SOAP requests and responses involved in Web services. Let's start with a simple example. As discussed earlier, for a component to be used as a Web service, it must have at least one method with access="remote". This same method, however, can be called by other ColdFusion templates on the server. It can also be called via Flash Remoting. What if you want to ensure that the method is only called as a Web service? ColdFusion MX 7 has a new function, isSoapRequest(), that returns true if the current method was executed as a Web service. Listing 24.18 demonstrates a simple Web service with a method that can only be called as a Web service.

Listing 24.18. A Web-Service-Only Component (justawebservice.cfc)

<cfcomponent>

  <cffunction name="test" returntype="string" access="remote">
         <cfif isSoapRequest()>
           <cfreturn "Good call!">
    <cfelse>
      <cfthrow message="This method must be called as a web service.">
    </cfif>
       </cffunction>

</cfcomponent>


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint