[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Consuming .NET web service from Coldfusion

Posted on 2009-04-29
9
Medium Priority
?
1,007 Views
Last Modified: 2013-12-24
We are trying to consume a .NET web service from Coldfusion 8.  There is a method called "getProducts()"  
When calling getProducts(), a dump reveals a set of other methods.   It is supposed to return a single string containing XML structured values.  

When attempting to use the get_any() method of getProducts, we just get more methods and fields..
(note the second screen shot does not contain everything)

Any idea where to find the expected string?

The author of the web service is working with us, so advice can be given for either end:  the .NET web service or the Coldfusion consuming side.   The author's intent is to make a web service easily accessible by various languages, so anything they need to know is also appreciated.


<cfset ws = CreateObject("webservice","http://theWebServiceURL.com/FormWiz/Wizard.asmx?wsdl")>
 
<cfset com = ws.GetProducts(variables.uname,variables.pswd)>
 
<cfdump var="#com#"> (see screen shot one) - We expected to see a string containing XML formatted values
 
 
<cfset xmlData = com.get_any()/>
 
<cfdump var="#xmlData[1]#">  (see screen shot two)

Open in new window

screen-capture-of-method-dump.jpg
screen-capture-get-any-dump.jpg
0
Comment
Question by:gdemaria
  • 4
  • 4
8 Comments
 
LVL 36

Expert Comment

by:SidFishes
ID: 24260184
Stupid isn't it...This should work for you


<cfset myStruct.result = structNew() />
<cfset myStruct.xmlData = getProducts.get_any() />
<cfset myStruct.mySchema = xmlParse(myStruct.xmlData[1]) />
<cfdump var="#myStruct.mySchema#">
0
 
LVL 39

Author Comment

by:gdemaria
ID: 24260339
Thanks Sid -  This is the solution I mentioned in the other question that didn't work for me.  The error I get initially is that the xmlParse can't find valid XML, so I simply dump the value of myStruct.xmlData[1] to see what exactly it looks like..

<cfset xmlData = com.get_any()/>
<cfdump var="#xmlData[1]#">

The dump result is what I have showing in image two above.  Nothing there looks much like a string.


to be more exacting, in case it matters, I used more of the format that you had suggested...

<cfset myStruct.result = structNew() />
<cfset myStruct.xmlData = ws.GetProducts(variables.uname,variables.pswd).get_any() />

<cfdump var="#myStruct.xmlData[1]#">

The same result.  


Btw, this line ...
<cfset myStruct.result = structNew() />

Should be ....
<cfset myStruct = structNew() />

Is that right?  Or is there something actually happening with a "result" element of this structure?




0
 
LVL 36

Expert Comment

by:SidFishes
ID: 24260462
"Should be ....
<cfset myStruct = structNew() />"

yes..

When I answered a similar q a while ago, I used cfinvoke and it worked. i wonder if .net wants uname=MyUname as opposed to just order of variable as in ws.GetProducts(variables.uname...

maybe try

<cfinvoke
 webservice="http://theWebServiceURL.com/FormWiz/Wizard.asmx?wsdl"
 method="getProducts"
 returnvariable="wsReturn">
        <cfinvokeargument name="uname" value="MyUname"/>
        <cfinvokeargument name="pwd" value="111111"/>
</cfinvoke>


<cfset myStruct = structNew() />
<cfset myStruct.xmlData = wsReturn.get_any() />
<cfset myStruct.mySchema = xmlParse(myStruct.xmlData[1]) />
<cfdump var="#myStruct.mySchema#">


0
Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

 
LVL 39

Author Comment

by:gdemaria
ID: 24260768
Sadly, it resulted in the the same dumps as pictured above.
Here is my resulting code:

<cfinvoke webservice="http://theWebServiceURL.com/xxxxWizard/Wizard.asmx?wsdl"
          method="getProducts" returnvariable="wsReturn">
  <cfinvokeargument name="login" value="#variables.uname#"/>
  <cfinvokeargument name="password" value="#variables.pswd#"/>
  <cfinvokeargument name="state" value="#variables.state#"/>
</cfinvoke>

<cfdump var="#wsReturn#">
<cfdump var="#wsReturn.get_any()#">


I've attached image captures of parts of the wsdl, in hopes that will help shed some light...

wsdl-part-1.jpg
wsdl-part-2.jpg
wsdl-part-3.jpg
0
 
LVL 36

Assisted Solution

by:SidFishes
SidFishes earned 2000 total points
ID: 24260959
disclaimer: i know nothing about creating .net webservices

Looking at the wsdl from the previous question i referred to (that worked), i see that there are some differences in the response section

specifically the nodes under (what would be) GetProductsResult

<s:element name="GetProductsResponse">
      <s:complexType>
            <s:sequence>
                  <s:element minOccurs="0" maxOccurs="1" name="GetProductsResult">
                        <s:complexType mixed="true">
                              <s:sequence>
                                    <s:any/>
                              </s:sequence>
                        </s:complexType>
                  </s:element>
            </s:sequence>
      </s:complexType>
</s:element>

as compared to what you've got


<s:element name="GetProductsResponse">
      <s:complexType>
            <s:sequence>
                  <s:element minOccurs="0" maxOccurs="1" name="GetProductsResult" type="s:string">
                  </s:element>
            </s:sequence>
      </s:complexType>
</s:element>

whether that's the issue or not is speculation but you may want to pass it on to your ws develpoer and see if it means anything to them...

0
 
LVL 39

Author Comment

by:gdemaria
ID: 24261080
Hmmm, good observation.

I wish the two were reversed, it's seems more logical that a response with a type of "String" is easier to work with than a response of time "complex Type mixed...."   :)

Yet, the complex one works, and the 'string' one does not...


Any thoughts about all those references to SOAP?

The ws developer showed me a .Net coded example which consumes his own web services and he uses SOAP to do so.   I told him I wasn't aware that he was using SOAP and he replied by saying that SOAP is entirely optional, I can consume it any way I'd like...   does that some right to you?   I thought if it uses it, I need to use it...  ?


0
 
LVL 36

Expert Comment

by:SidFishes
ID: 24261211
afaik, you should be able to get the response without using soap (but it's worth trying)

the other thing is that GetProductsResponse does not have a <s:any/> node so I'm wondering how get_any() works without it. Maybe soap doesn't need it but cfinvoke/createObject does?

(again this is just guess work at this point)
0
 
LVL 39

Accepted Solution

by:
gdemaria earned 0 total points
ID: 24859294
No solution was found.

I am objecting to the auto-close so that I can accept multiple solutions and award points.
There is an EE bug that once an auto-close is in place, the option to accept multiple solutions is hidden, to get around this, the auto-close must be objected-to and then the option appears.

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question