• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Consuming WS blues

New Here ,
Apr 02, 2009 Apr 02, 2009

Copy link to clipboard

Copied

Hi Everyone,
I just got started on a site which needs to pull data via a SOAP WS. Whilst I have a bit of experience with CF and conventional datasources I have never used a WS before.

The WSDL is located here:
http://www.villarenters.com/VillarentersWebService/VillaSearch.asmx?WSDL

and I used the attached code to try and pull data.

I respectively got the following error messages :

Cannot generate stub objects for web service invocation.

Name: http://www.villarenters.com/VillarentersWebService/VillaSearch.asmx/GetChildLocationsV2?ParentID=0&V... WSDL: http://www.villarenters.com/VillarentersWebService/VillaSearch.asmx/GetChildLocationsV2?ParentID=0&V... WSDLException (at /ChildLocationV2): faultCode=INVALID_WSDL: Expected element '{ http://schemas.xmlsoap.org/wsdl/}definitions'.: It is recommended that you use a web browser to retrieve and examine the requested WSDL document to ensure it is correct. If the requested WSDL document cannot be retrieved or is dynamically generated, it is likely that the target web service has programming errors.

And

Web service operation GetChildLocationsV2 with parameters {Parent_ID={0}} cannot be found.

So I thought that the WSDL file was malformed. However when I paste this into my browser :

http://www.villarenters.com/VillarentersWebService/VillaSearch.asmx/GetChildLocationsV2?ParentID=0&V...

it returns the correct data so that same WSDL file is working when called from their own website.

I am starting to think maybe an ASP.NET vs CF incompatibility ???

Do I need to use the arguments in both the url of the WS and in the <CFInvokeArgument> tag? Or can I dispense with one of them?

I would really be grateful for any help on this as I am well and truly stuck :)
Thanks, Paul.
TOPICS
Advanced techniques

Views

1.8K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 05, 2009 Apr 05, 2009

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 06, 2009 Apr 06, 2009

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:

Deprecated features

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:

  • rpc as the SOAP binding style and encoding as the encodingStyle
  • document as the SOAP binding style and literal as the encodingStyle

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 06, 2009 Apr 06, 2009

Copy link to clipboard

Copied

I use Dreamweaver to work with Web-services, and everything works perfectly!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 06, 2009 Apr 06, 2009

Copy link to clipboard

Copied

Are you using CS4?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 07, 2009 Apr 07, 2009

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 07, 2009 Apr 07, 2009

Copy link to clipboard

Copied

Are you using CS4?

Yes

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 07, 2009 Apr 07, 2009

Copy link to clipboard

Copied

OK, that's interesting. When I open the components panel I see:

components.png

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 07, 2009 Apr 07, 2009

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 07, 2009 Apr 07, 2009

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.

Untitled.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 07, 2009 Apr 07, 2009

Copy link to clipboard

Copied

Look at my screenshot

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 07, 2009 Apr 07, 2009

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2009 Apr 13, 2009

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 28, 2009 Apr 28, 2009

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 28, 2009 Apr 28, 2009

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation