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

Correct way of displaying result from a complex type result of webservice

Community Beginner ,
Oct 06, 2006 Oct 06, 2006

Copy link to clipboard

Copied

Hi,

I’m trying to call a webservice with the following code and expect to dump a list of country but when I try to dump it I am getting the following methods.

<cfscript>
ws = createObject("webservice", " http://sandbox.voxbone.com/ws/services/VoxService?wsdl");
myReturnVar = ws.getCountriesList(args);
</cfscript>

<cfoutput># myReturnVar.ctry#</cfoutput>
<cfdump var="# myReturnVar#">

1st DUMP:
voxbone.webservices.services.containers.ArrayOfCountry@94185581
object of voxbone.webservices.services.containers.ArrayOfCountry
Methods hashCode (returns int)
equals (returns boolean)
getCountry (returns [Lvoxbone.webservices.services.containers.Country;)
getCountry (returns voxbone.webservices.services.containers.Country)
getSerializer (returns interface org.apache.axis.encoding.Serializer)
getDeserializer (returns interface org.apache.axis.encoding.Deserializer)
getTypeDesc (returns org.apache.axis.description.TypeDesc)
setCountry (returns void)
setCountry (returns void)
getClass (returns java.lang.Class)
wait (returns void)
notify (returns void)
notifyAll (returns void)
toString (returns java.lang.String)


On my 1st DUMP, I can see two (2) getCountry() methods and tried the following code and do a 2nd DUMP if I can display the data I want but when I tried to dump it I am getting another hierarchy of methods ( please see below 2nd DUMP). Now the error comes when I try to dump getCountryName() method to display country name for example but it gives me function not found. Can someone help me what is the correct way of displaying data from a web service result? Thank you and really appreciate any input.

<cfscript>
ws = createObject("webservice", " http://sandbox.voxbone.com/ws/services/VoxService?wsdl");
myReturnVar = ws.getCountriesList(args);

realStruct = structNew();
realStruct.ctry = myReturnVar.getCountry();
</cfscript>

<cfoutput>#realStruct.ctry#</cfoutput>
<cfdump var="#realStruct.ctry#">

2nd DUMP:

Lvoxbone.webservices.services.containers.Country;@11e3923
array
1 object of voxbone.webservices.services.containers.Country
Methods hashCode (returns int)
equals (returns boolean)
getSerializer (returns interface org.apache.axis.encoding.Serializer)
getDeserializer (returns interface org.apache.axis.encoding.Deserializer)
getTypeDesc (returns org.apache.axis.description.TypeDesc)
getAvailableDidsCount (returns int)
setAvailableDidsCount (returns void)
getCountryCodeA2 (returns java.lang.String)
setCountryCodeA2 (returns void)
getCountryName (returns java.lang.String)
setCountryName (returns void)
getCountryPhoneCode (returns int)
setCountryPhoneCode (returns void)
getClass (returns java.lang.Class)
wait (returns void)
wait (returns void)
wait (returns void)
notify (returns void)
notifyAll (returns void)
toString (returns java.lang.String)


TOPICS
Advanced techniques

Views

365

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
Participant ,
Oct 17, 2006 Oct 17, 2006

Copy link to clipboard

Copied

These complex types are a challenge...
It returns a complex type array. You have to invoke the getCountry method to create the array. Try this.

<cfset aCountries = results.getCountry() />
<cfloop index="i" from="1" to="#ArrayLen(aCountries)#>
#aCountry .country#
</cfloop>

I found this link helpful: http://www.webreference.com/programming/coldfusion/1/5.html

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 ,
Oct 23, 2006 Oct 23, 2006

Copy link to clipboard

Copied

LATEST
Actually, the suggested way to do it is for each get method, e.g. getCountry(), use dot notation.
result.aCountries[1].country

You can check with properties are accessable by dumping StructKeyArray(webServiceResult) which is much easier to decipher than the dump of a complex type.

Finally, if using CF7, you can get the RAW xml that came from your SOAP request. You might find this easy to navigate after dumping it to examine its structure. This approach is more useful for Document Literal style services.

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