Consuming a webservice using a local WSDL

Code , ColdFusion Add comments

We recently had to connect to a webservice without a publically available WSDL and ran into a few gotchas.

Why would anyone want to do this? Well, the webservice may not be for public consumption, or as an extra security measure, the webservice hoster may not want to publically expose available methods.

So the first thing you'll need to do is get a WSDL from whoever is hosting the web service. Place it in a folder under your webroot on your server, and then restrict access to that folder to your machine's local IP (see this entry for info on locking down a folder in IIS).

While on your machine, you should be able to browse to the WSDL directly (tested in IE, I don't have another browser on my server). This is the first place we ran into trouble. Initially, only two out of four webservers would see the WSDL. The other half returned a 404 even though the file was in plain view. The fix for this was far from obvious and completely nonsensical. After much investigation we concluded the only difference in the environments was ASP.NET was installed on the two that worked. So, we installed ASP.NET across the board and all the machines magically rendered the WSDL in IE.

Now to invoke the webservice in ColdFusion:

<cftry>
<cfinvoke webservice="http://www.yoursite.com/wsdl/someWSDL.wsdl"
    method="someMethod"
    returnvariable="wsresult">
  <cfinvokeargument name="arg1" value="123">
  <cfinvokeargument name="arg2" value="abc">
</cfinvoke>

<cfdump var="#wsresult#">
<cfcatch type="any">
  <cfdump var="#cfcatch#">
</cfcatch>
</cftry>

If your hosting environment is extremely locked down, you may have to have a hole punched in your firewall to the destination IP where the webservice lives.

You may have other issues, but I hope, for your sake, that you don't.

:)

2 responses to “Consuming a webservice using a local WSDL”

  1. MrBuzzy Says:
    Possibly what's happening here is: installing ASP.NET adds .WSDL to the allowed extensions and mime-types. You could do this yourself in IIS admin. Or you could save the WSDL as .xml instead and possibly avoid the issue all together.
    Or, save the local WSDL as .cfm to get some extra benefits. For example you could secure the wsdl with Application.cfc.
    HTH. Cheers.
  2. nagrom Says:
    @buzz,
    Thanks for the info! I found a server around here without .NET and lo and behold, .wsdl was not in the MIME types for IIS. We did try saving the WSDL as a .cfm but it wouldn't parse properly.

Leave a Reply



Powered by Mango Blog. Design and Icons by N.Design Studio