Skip navigation
CFBYSTANDER
Currently Being Moderated

WSDL ColdFusion version visible - need it hidden

Apr 17, 2012 10:03 AM

Tags: #wsdl #cfc

I have a web service and the auto generated WSDL at http://mysite/webservice.cfc?wsdl includes the full ColdFusion version number in comments on the second line of the WSDL.
E.G. <!--WSDL created by ColdFusion version 9,0,1,274733-->

 

The example on http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859 461172e0811cbec22c24-78a6.html shows the comment as:

<!--WSDL created by ColdFusion -->

 

Is there a production style setting that can be used to hide this version number when auto generating the WSDL?

Alternatively, is the auto generated WSDL stored temporarily on the CF server that can be read and edited onRequestStart and returned instead of the originally auto generated WSDL?

 

I know i can set the "wsdlFile" property to a specific WSDL file that I can edit to remove the version number in webservice.cfc but I wanted to avoid having to manually maintain the WSDL.

 

Thanks in advance for any assistane with this.

 

Tom

 
Replies
  • Currently Being Moderated
    Apr 19, 2012 6:26 AM   in reply to CFBYSTANDER

    CFBYSTANDER wrote:

     

    I have a web service and the auto generated WSDL at http://mysite/webservice.cfc?wsdl includes the full ColdFusion version number in comments on the second line of the WSDL.
    E.G. <!--WSDL created by ColdFusion version 9,0,1,274733-->

     

    The example on http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859 461172e0811cbec22c24-78a6.html shows the comment as:

    <!--WSDL created by ColdFusion -->

    This is to be expected. It is traditional for text or code generators to include their signature. ColdFusion does it subtly, using a comment. Some generators actually include a 'live' header, comprising many lines!

     

    Is there a production style setting that can be used to hide this version number when auto generating the WSDL?

    Alternatively, is the auto generated WSDL stored temporarily on the CF server that can be read and edited onRequestStart and returned instead of the originally auto generated WSDL?

    I haven't looked into the inner workings ColdFusion's WSDL generation, but experience tells me it is unlikely that ColdFusion maintains a temporary store for WSDLs. I expect a WSDL to be generated either on the fly or from cache.

     

    That is also what you would hope for. You would want the WSDL to reflect changes you make in your CFC. Also, if you made no changes, you would want ColdFusion to use the cached version, instead of going to all the trouble of generating the WSDL again. 

     

    I know i can set the "wsdlFile" property to a specific WSDL file that I can edit to remove the version number in webservice.cfc

    That seems like a good workaround to me.

     

    Added update:

     

    I wanted to avoid having to manually maintain the WSDL.

     

    Remember that the WSDL is available through, for example:

     

    <cfhttp method="get" url="http://mysite/webservice.cfc?wsdl">

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 19, 2012 8:27 AM   in reply to CFBYSTANDER

    That is one fact you can count on: your solution will certainly help others.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 21, 2012 2:27 AM   in reply to CFBYSTANDER

    Sorry I don't quite understand the reasoning behind your code. I expected no locks, and that you would write to file somewhere. What are the 2 structdeletes at the end for? Were you aiming for something like this?

     

    <cffunction name="onRequestStart" returnType="boolean" output="no">

    <cfargument name="targetPage" type="string" required="true">

    <cfif listLast(arguments.targetPage,".") EQ "cfc" AND lcase(CGI.QUERY_STRING) EQ "wsdl">

        <!--- need application.InterceptWSDL to avoid infinite loop and subsequent timeout. Otherwise the cfhttp request would keep requesting itself when it hits onRequestStart --->

        <cfif NOT structKeyExists(application, "InterceptWSDL")>

            <cfset application.InterceptWSDL = 1>

            <cfhttp url="http://mysite/#targetPage#?wsdl" method="get" charset="utf-8" timeout="20" result="GeneratedWSDL" /> 

            <cfset newWSDL = REReplaceNoCase(GeneratedWSDL.filecontent, "<!--WSDL created by ColdFusion [A-Z0-9 ,-->]*\r\n", "", "ALL")>     

            <cffile action="write" file="absolute-path-to-wsdl-file" output="#newWSDL#" >

            <cfelse>

            <!--- the code below should only run when the cfhttp request is made --->

            <cfset structdelete(application, "InterceptWSDL")>

        </cfif>

    </cfif>

    <cfreturn true>

    </cffunction>

     

    In any case, I wouldn't implement this at the start of every request. I wouldn't wish to do anything in Application.cfc when the client invokes the web service. A web service call is a contract between server and client. Putting obstacles in the way of the call may be considered to be a breach of that contract.

     

    Also, a service shouldn't be changing on the fly. In fact, it takes a while for the CFC of a web service to change. One would therefore expect that the WSDL will remain the same for a while.

     

    So, the way I would do it would be to clean up the WSDL at selected moments of my own choosing. I would use a CFM page dedicated to that purpose.

     

    The CFM file would grab the WSDL by means of cfhttp, and strip off the offending comment line, as you have done. The result will be written to file, using cffile. Then the <cfcomponent> tag for the web service would include the attributes style and wsdlfile.

     

    I would perhaps only use onRequestStart to check for permission to modify WSDLs. For example, let's say, I expect the request to the CFM page to be something like this, where the webservice is Customer.cfc:

     

    http://www.mydomain.com/services/conf/modifyWSDL.cfm?wsdl=customer&cod e=47AC6b0f928Ee15d

     

    Then I would implement something like this in onRequestStart:

     

    <cfif listLast(arguments.targetPage,"/") EQ "modifyWSDL.cfm">

    <cfif NOT structKeyExists(URL,"wsdl") OR NOT structKeyExists(URL,"code") OR NOT (compareNoCase(url.code, "47ac6b0f928ee15d") EQ 0)>

        <!--- redirect to permission-refused page --->

    </cfif>   

    </cfif>

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points