Copy link to clipboard
Copied
Copy link to clipboard
Copied
If you have Dreamweaver, you can use it to generate code for web-services.
Just open the "Components", select in drop-down menu "Web services" and enter the URL of service. Dreamweaver show to you available functions and generate code for their use.
Like this:
<cfinvoke
webservice="http://www.villarenters.com/VillarentersWebService/VillaSearch.asmx?WSDL"
method="villaSearch"
returnvariable="aVillaResults">
<cfinvokeargument name="rag" value="enter_value_here"/>
<cfinvokeargument name="strOwnerRefs" value="enter_value_here"/>
<cfinvokeargument name="strPropRefs" value="enter_value_here"/>
<cfinvokeargument name="strLocationRefs" value="enter_value_here"/>
<cfinvokeargument name="intMaxPrice" value="enter_value_here"/>
<cfinvokeargument name="intMinPrice" value="enter_value_here"/>
<cfinvokeargument name="intSleeps" value="enter_value_here"/>
<cfinvokeargument name="blnInstantBooking" value="enter_value_here"/>
<cfinvokeargument name="intVillarentersIndex" value="enter_value_here"/>
<cfinvokeargument name="intDiscountType" value="enter_value_here"/>
<cfinvokeargument name="intBranding" value="enter_value_here"/>
<cfinvokeargument name="intPage" value="enter_value_here"/>
<cfinvokeargument name="intItemsPerPage" value="enter_value_here"/>
<cfinvokeargument name="blnEnableAvailabilitySearch" value="enter_value_here"/>
<cfinvokeargument name="strFromYYYYMMDD" value="enter_value_here"/>
<cfinvokeargument name="strToYYYYMMDD" value="enter_value_here"/>
<cfinvokeargument name="intSortOrder" value="enter_value_here"/>
</cfinvoke>
Copy link to clipboard
Copied
Thanks for that Alexei. I have CS4 trial installed right now (which I am not impressed with!) and it seems that the web services feature has been dropped since CS3..... Unless I am missing something?
From the Dreamweaver CS4 Manual:
The following features have been deprecated for Dreamweaver CS4:
Timelines
Web services
Layout mode
Site Map view
Java Bean support
Adobe® Flash elements (Image Viewer)
Adobe® Flash text and Adobe® Flash buttons
ASP.NET and JSP server behaviors and recordsets
I have now tried lots of variations and still can't get it to talk. Also from the LiveDocs I found :
To consume a web service that is implemented in a technology other than ColdFusion, the web service must have one of the following sets of options:
Can anyone tell me for sure if the WSDL file that I am using complies with these requirements. I called the company who's WS is it and they were "fairly" sure that it complies with the second option.... but they weren't committing themselves!
Copy link to clipboard
Copied
I use Dreamweaver to work with Web-services, and everything works perfectly!
Copy link to clipboard
Copied
Are you using CS4?
Copy link to clipboard
Copied
OK, so I finally managed to get this working. I found a good reference at :
http://www.jamesnetherton.com/blog/2007/01/14/Invoking-a-webservice-using-CFHTTP/
and after minimal tinkering I made it work with the WS I am trying to use.
<cfsavecontent variable="soap"> <?xml version="1.0" encoding="UTF-8"?> <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> <ns1:GetChildLocationsV2 soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://directorypath"> <ParentID xsi:type="xsd:double">3924</ParentID> </ns1:GetChildLocationsV2> </soapenv:Body> </soapenv:Envelope> </cfsavecontent> <!--- Note that there's no ?wsdl appendage to the url ---> <cfhttp url="http://www.villarenters.com/VillarentersWebService/VillaSearch.asmx" method="post"> <cfhttpparam type="header" name="content-type" value="text/xml"> <cfhttpparam type="header" name="SOAPAction" value="http://tempuri.org/VillarentersWebService/villa_search/GetChildLocationsV2"> <cfhttpparam type="header" name="content-length" value="#len(soap)#"> <cfhttpparam type="header" name="charset" value="utf-8"> <cfhttpparam type="xml" name="message" value="#trim(soap)#"> </cfhttp> <cfoutput> <p>#cfhttp.filecontent#</p> </cfoutput>
I hope this is useful for someone.
Copy link to clipboard
Copied
Are you using CS4?
Yes
Copy link to clipboard
Copied
OK, that's interesting. When I open the components panel I see:
As I understand it the drop-down should have a web services option - is that right? The only option I have is CF Components. Am I missing something?
Copy link to clipboard
Copied
Choose in drop-down menu "Web services" and click "+", then enter URL of web service. Dw check it and show to you avalaible methods. Next you can drag needed method to your page
Copy link to clipboard
Copied
Sounds too easy
But I don't have "Web Services" in the drop-down, just CF Component. I have looked through the prefs for DW but can't find anything there to enable WS functionality.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
OK, so now you have got me jealous and confused
I'll try and contact DW support and see if they can tell me how I can get the web services in my drop-down.
Copy link to clipboard
Copied
From the Dreamweaver Documentation on consuming web services:
Note: This section makes use of a Dreamweaver CS4 feature that is only available on Windows machines. You will not be able to introspect a web service on a Mac OS X machine. You can, of course, still use ColdFusion on Mac OS X and run code that makes use of web services. You just can't use the built-in Dreamweaver's tool to examine the web service.
I am on a Mac hence why I don't get the web services option in my drop-down list. Mystery solved
Copy link to clipboard
Copied
Dreamweaver integration aside, you should be able to hand-code the web service call without too much dificulty. From what I can tell it looks like you had a couple of problems with your initial web service invocation call, based on your first post. Can you verify the following:
1) That your <cfinvoke> webservice attribute is pointing to: http://www.villarenters.com/VillarentersWebService/VillaSearch.asmx?WSDL
2) That you are passing in ALL expected parameters of the web service method? CF will freak out on you if you leave a parameter out of a web service call (even if it is an optional one). You can try using the "omit" parameter, but I find that that does not always do the trick.
Based on the error messages that you were receiving from your initial post, it looks like you may have been pointing your webservice to the GET form of the web service call instead of the WSDL, and your second error message only includes the value of one of the web service parameters.
If you are still having problems, can you post your invocation code so we can troubleshoot your problem?
Hope that helps,
- Michael
Copy link to clipboard
Copied
Hi Michael,
When I realised that DW wasn't going to help me out with using the web service I decided to get my hands dirty and look at coding the WS calls by hand. I found a good resource on a blog ( http://www.jamesnetherton.com/blog/2007/01/14/Invoking-a-webservice-using-CFHTTP/ ) and modified slightly to suit my requirements and it has been working beautifully.
The code now looks like this:
<cffunction name="getAllLocations" returnType="xml"> <cfargument name="ParentID" required="true" type="numeric"> <cfargument name="VRF" required="false" type="string"> <cfsavecontent variable="soap"> <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <GetChildLocationsV2 xmlns="http://tempuri.org/VillarentersWebService/villa_search"> <cfoutput> <ParentID xsi:type="xsd:string">#ParentID#</ParentID> <VRF xsi:type="xsd:string"></VRF> </cfoutput> </GetChildLocationsV2> </SOAP-ENV:Body> </SOAP-ENV:Envelope> </cfsavecontent> <cfhttp url="http://www.villarenters.com/VillarentersWebService/VillaSearch.asmx" method="post" timeout="90"> <cfhttpparam type="header" name="content-type" value="text/xml"> <cfhttpparam type="header" name="SOAPAction" value="http://tempuri.org/VillarentersWebService/villa_search/GetChildLocationsV2"> <cfhttpparam type="header" name="content-length" value="#len(soap)#"> <cfhttpparam type="header" name="charset" value="utf-8"> <cfhttpparam type="xml" name="message" value="#trim(soap)#"> </cfhttp>
<cfset xmlLocations = xmlParse(ReReplaceNoCase(#cfhttp.fileContent#, "<soap:[^>]*>|</soap[^>]*>|<GetChildLocationsV2Response[^>]*>|</GetChildLocationsV2Response[^>]*>", "", "ALL" )) />
<cfreturn xmlLocations> </cffunction>
I put all that into a cfc and I just make the call to it using either :
<cfinvoke component="getLocations" method="getAllLocations" returnVariable="xmlLocations"> <cfinvokeargument name="ParentID" value="#URL.ParentID#"> </cfinvoke>
or this:
<cfset objXml = createObject("component","getLocations")> <cfset xmlLocations = "#objXml.getAllLocations(ParentID)#">
I did struggle a bit with this as I hadn't been coding for a number years and SOAP was completely new to me but once I got comfortable with it I realised that it's no big deal.
Thanks for the help,
Paul.