Copy link to clipboard
Copied
I need help in getting the value of the following xml node called MemberInformation's Last_Updated's value (see below)
I got all the values such as the id, addr1,addr2,addr3,addr4, city,state,zip and country but can get the Lat_Updated value back
I got the id's values back but why not last_updated values??? do I need a certain tehnique to get the second nodes of MemberInformation?
Please help!
Here is how I invoke my xml (see the xml below my cfinvoke tags):
<cfinvoke webservice="https://someurl.asmx?wsdl" method="GetMembersChangedSince" returnvariable="result4">
<cfinvokeargument name="login" value="xxxxxxxxxxxxxx">
<cfinvokeargument name="password" value="xxxxxxx">
<cfinvokeargument name="columns" value="id,addr1,addr2,addr3,addr4,city,state,zip,country,last_updated"> <------?????
<cfinvokeargument name="changedColumns" value="">
<cfinvokeargument name="changedSince" value="2010-07-21">
<cfinvokeargument name="includeNonMembers" value="TRUE">
<cfinvokeargument name="includeBlankIds" value="FALSE">
<cfinvokeargument name="filter" value="[id] LIKE '0%'">
</cfinvoke>
Copy link to clipboard
Copied
This article http://www.adobe.com/livedocs/coldfusion/6.1/htmldocs/xml34.htm will show you some of the syntax you'll have to use.
Copy link to clipboard
Copied
OK. But what have you yourself tried so far?
--
Adam
Copy link to clipboard
Copied
This is how I tried so far:
(here is the wsdl file : https://admin.imodules.com/ws_20/generalquery.asmx?wsdl )
1. Invoking the web services using cfinvoke as written on my first post
2. My CFINVOKE returns an Array, Here is what I did to this array:
<CFSET MemberInfo_2 = result4.getMemberInformation()>
<CFIF IsDefined("MemberInfo_2")>
<CFSET Call_DateSince_2(#MemberInfo_2#,'#url.changesince#')>
</CFIF>
3. Looping each array element and calling getColumn
<CFFUNCTION name="Call_DateSince_2" hint="Processing Original address step 1">
<cfargument name="Arr_MemberInfo_2" type="Array" required="true">
<cfargument name="DateChangeType_2" type="String" required="true">
<cfloop from="1" to="#arraylen(arguments.Arr_MemberInfo_2)#" index="i">
<CFSET GetAddress(arguments.Arr_MemberInfo_2.getColumn(),i,arguments.DateChangeType_2)>
</cfloop>
</CFFUNCTION>
4. I'm able to update my addr. table with all the columns EXCEPT last_updated
<CFFUNCTION name="GetAddress" hint="Processing Original address step 2">
<cfargument name="MemberInfoArray" type="Array" required="true">
<cfargument name="SeqId" type="Numeric" required="true">
<cfargument name="DateChangeType" type="String" required="true">
<cfset st_OrigAddr = StructNew()>
<cfloop from="1" to="#arraylen(arguments.MemberInfoArray)#" index="j">
<cfset st_OrigAddr["#arguments.MemberInfoArray
</cfloop>
<cfquery name="UpdateAddrTable"datasource="AddrDB">
UPDATE AddrTable
SET addr1 = <cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["addr1"]#">,
addr2 =
<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["addr2"]#">,
addr3 =
<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["addr3"]#">,
addr4 =
<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["addr4"]#">,
city =
<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["city"]#">,
state =
<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["state"]#">,
zip =
<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["zip"]#">,
country =
<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["country"]#">,
busaddr1 =
<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["busaddr1"]#">,
busaddr2 =
<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["busaddr2"]#">,
busaddr3 =
<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["busaddr3"]#">,
buscity =
<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["buscity"]#">,
busst =
<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["busst"]#">,
buszip =
<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["buszip"]#">,
buscountry =
<cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["buscountry"]#">
WHERE id = <cfqueryparam cfsqltype="cf_sql_varchar" value="#st_OrigAddr["id"]#">
</cfquery>
</CFFUNCTION>
Copy link to clipboard
Copied
Yikes. Too much code!
The question you're asking is how to get a value from an XML node. You don't need to post functions & queries and that sort of stuff... just start with some XML (you've posted that), and the code you have tried to use to get your value from it. Factor it out of all the other stuff... there's no point thinking about that until you are clear on how to get the node value out of the XML.
Your code should be something like:
<cfxml variable="x">
<!--- xml in here --->
</cfxml>
<cfset someVariable = [some code you have used to get your node value]>
(it might be more than one line of code, but you get my drift)
Once you're clear on what [some code you have used to get your node value] is, then you can reintegrate it into the rest of the code.
You are trying to do too much @ once here, I think.
--
Adam
Copy link to clipboard
Copied
but all I have is just:
Copy link to clipboard
Copied
So your question isn't "how you get the last_updated value from the XML", it's more "how do I use the https://admin.imodules.com/ws_20/generalquery.asmx?wsdl API to [do something to do with the last_updated column]?"
Although this doesn't seem right. It seems from your code that you can call the webservice just fine, and you get some XML back. Then you want to do [something] to the XML. I assumed you wanted to extract the last_updated attribute value from it?
Note that in your original post, you are treating last_updated as a COLUMN, whereas - looking @ the XML - it's not a column, it's an attribute of the MemberInformation node. And there doesn't seem to be anything in the WSDL to suggest you can filter on that value.
So... what is it you actually need to do. Don't think in terms of code to do it, just explain what you are wanting to do, and where you're coming unstuck...
--
Adam
Copy link to clipboard
Copied
Yes, you are right. I need to use the
https://admin.imodules.com/ws_20/generalquery.asmx?wsdl API to get some columns (the addresses such as address1, address2,
city, zip,country) and the Constituen_id.
At first, I thought last_updated was a column but then realized it was not. That's when I got stucked, I did not know how to extract the last_updated attribute value for each address
The company provides me with the url (https://admin.imodules.com/ws_20/generalquery.asmx?wsdl)
When I get rid of ?wsdl from the url, I see several links. What I need is the GetMembersChangedSince
so I clicked on that link and I see a form.
I relate this form to my cfinvioke I posted the first time (on the TOP of this forum).
When I fill in all the parameters from my cfinvoke to this form and click on INVOKE button, this is what I get (see below)
So, it is not possible to get the value of Last_Updated value? which is 2010-08-10T16:43:51?
Copy link to clipboard
Copied
OK, so you are getting the whole XML back fine, including the value you want.
It's just a matter of - given that XML you have - how do you extract the Last_Updated value.
Have you read up on CF's XML support:
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7fb3.html
This goes through accessing an XML doc:
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec133ba-7fe6.html
There's also a bunch of XML functions:
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec1a60c-7ffc.html#WSc3ff6d0ea77859461172e0811cbec22c24-69fb
In particular xmlSearch() is probably gonna help you:
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-78e8.html
If you don't know how XPath works, there are some good tutorials here:
http://www.zvon.org/comp/r/tut-XPath_1.html#
Basically if you you the XML schema and want a specific node / attribute, you can use the dot- & array-notation as per the second link I gave you. If you want to get out a bunch of matching nodes or attributes from the XML (eg you have ten MemberInformation nodes in your XML, and you want the Last_Updated attribute value from all of them), using xmlSearch() and XPath are probably a better bet.
That should be enough to get you moving fwd...
--
Adam
Copy link to clipboard
Copied
Adam, Thanks for all the help you have given me so far but the more I read the more I get confuse.
Now that most of my codes are working I'm not sure where should I start with getting last_updated value. Is this a 2 step process where first I got all the values for the columns and then I have to write a whole different codes to get last_updated values???
I have never used XPath not XMLSearch before and by invoking web services using CFInvoke, I got a return value, which in this case, I called it result4
I can't use this result4 in XPath because it is not an xml object (?)
Copy link to clipboard
Copied
What Adam is pointing out is that you are getting a result that is a complex type. The complex type is called XML. Which is made up of various smaller types.
You are trying to access one specific piece of the complex variable. There are various ways to pare down this complex variable such as accessing nodes with array [] and or dot . syntax. Or using XML functions such as xmlSearch() or xmlTransform().
You may also need to use the xmlParse() to turn the string representation of the XML into an actual XML variable object representation in ColdFusion's memory.
Copy link to clipboard
Copied
I got that but the problem is when I invoke the wsdl, I got a result and this is all I get
the result is not xml. I did:
<CFSET x = "#XMLParse(x)#"> or <CFSET x = "#XMLTransform(x)#"> I got an error saying x is NOt xml
I did <CFSET x = "#IsXml(x)#"> I got NO as a result
How to turn this result into xml
Copy link to clipboard
Copied
What do you get if you <cfdump> it?
--
Adam
Copy link to clipboard
Copied
<cfinvoke webservice="https://admin.imodules.com/ws_20/generalquery.asmx?wsdl" method="GetMembersChangedSince" returnvariable="result4">
<cfinvokeargument name="login" value="xxxxxxxxx">
<cfinvokeargument name="password" value="xxxxxxx">
<cfinvokeargument name="columns" value="id,addr1,addr2">
<cfinvokeargument name="changedColumns" value="">
<cfinvokeargument name="changedSince" value="2010-07-31">
<cfinvokeargument name="includeNonMembers" value="TRUE">
<cfinvokeargument name="includeBlankIds" value="FALSE">
<cfinvokeargument name="filter" value="[id]='0001124419'">
</cfinvoke>
<CFSET x = result4>
<cfdump var="#x#" label="result4">
If I do the following, I got this error:
<CFSET y = "#IsXml(x)#">
<cfdump var="#y#" label="y">
I got : NO
Copy link to clipboard
Copied
It's not an error, it's an object, and it's listing its method signatures.
I imagine if you call x.getMemberInformation(), you'll get the XML.
Dump that out, and see what you get:
<cfdump var="#x.getMemberInformation()#">
--
Adam
Copy link to clipboard
Copied
Actually, now that I look @ the WSDL, it seems it returns an array, not XML. But dump it out anyhow, and let's see what's in there...
--
Adam
Copy link to clipboard
Copied
Sorry for not responding but our county got hit by a storm since the 16 and we had no electricity until today.
Correction on my previous post, I did not mean to point the image I posted above as an error but as you said those were object with methods and properties. It is these methods that I had used to get the values of columns except last_updated is not a column and that's why I did not get anything back.
You are also correct, I did not get an xml but an array of these objects.
In order to post the image here I just limit one array with 1 object element instead of an array with 80 some elements.
Anyway all the element show the same object.
Here it is:
From the cfdump I posted above, I did:
<CFSET MemberInfo = result3.getMemberInformation()>
<CFIF IsDefined("MemberInfo")>
<cfdump var="#MemberInfo#">
</CFIF>
Here is the output:
From here I did:
<cfset LastUpdated = "#MemberInfo[1].getLast_Updated()#">
<cfdump var="#LastUpdated#">
Here is the output:
Copy link to clipboard
Copied
It shouldn't be too difficult to convert that GregorianCalendar obejct into a CF date?
http://download-llnw.oracle.com/javase/6/docs/api/java/util/GregorianCalendar.html
It's a shame you have to grab all the objects and then filter out the ones you want, but that's about as good as it gets with the API you'ev been given, it seems.
--
Adam
Copy link to clipboard
Copied
Adam, from what you can see so far is working with gregorian calender the easiest approached?
There is no CF function that can grab the last_updated from MemberInfo attribute node?
The vendor used to treat last_updated as column but suddenly they changed it without notice
Copy link to clipboard
Copied
I am very confused. You talk about this XML existing, but from what you're telling us (and showing us) the web service calls are returning arrays of objects, not XML.
--
Adam