Copy link to clipboard
Copied
I am dipping my toe into the web service world and have a web service from Oracle that I am trying to consume. It is not working as I thought, so any pointers are appreciated.
Here is the cfinvoke code...
<cfinvoke
webservice="http://erpintsrv1-dc-aus:7777/arWs/arWsSoapHttpPort?WSDL"
method="customerXML"
returnvariable="a_customerXMLResponseElement">
<cfinvokeargument name="parameters" value="123456" />
</cfinvoke>
<cfdump var="#a_customerXMLResponseElement#">
Here is the result...
Here is the result from the Oracle interface...
<env:Envelope
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns0="http://xxas/integration/arws/ArWs.wsdl/types/">
<env:Body>
<ns0:customerXMLResponseElement>
<result>
<ROWSET>
<ROW
num="1">
<CUSTOMER_NUMBER>123456</CUSTOMER_NUMBER>
<CUSTOMER>MOUNTAIN BUILDING SUPPLY, INC #8228</CUSTOMER>
<PLATFORM>500</PLATFORM>
</ROW>
</ROWSET>
</result>
</ns0:customerXMLResponseElement>
</env:Body>
</env:Envelope>
My thought was once I invoked the web service and dumped it to the page, I would see the above info (customer name, platform, etc.) Instead, I seem to get java class names, methods, etc. Thoughts?
I'd use Xpath via CF's XMLSearch function to search the result document and pull out the data you need. See a basic sample below. If this sample doesn't fit your needs please let me know.
For an overview of Xpath see http://msdn.microsoft.com/en-us/library/ms256115.aspx
<!--- sample data --->
<cfsavecontent variable="serviceResult">
<result>
<ROWSET>
<ROW num="1">
<CUSTOMER_NUMBER>019889</CUSTOMER_NUMBER>
<CUSTOMER>MOUNTAIN BUILDING SUPP
Copy link to clipboard
Copied
Anyone out there have any thoughts on this?
Copy link to clipboard
Copied
Warning: this is a shot in the dark.
Does a cfdump of a_customerXMLResponseElement.get_any() return an XML document or CF struct? This Oracle service's "get_any()" method in your cfdump looks similar to how CF interprets .NET datasets returned from a web service. In a .NET web service the SOAP type "any" is used when the results are to be sent as XML without a specific schema.
Can you post the WSDL for this web service?
Copy link to clipboard
Copied
Here is the dump of getAny()...
array | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 |
|
Copy link to clipboard
Copied
Here is the WSDL...
Copy link to clipboard
Copied
It looks like you're getting an array containing a single Apache Axis MessageElement object. I'd take a look at the Axis documentation and see if it is helpful. You might try something like: a_customerXMLResponseElement.get_any()[1].getValue() . This *might* return the underlying XML as a string.
Apache Axis Documentation for org.apache.axis.message.MessageElement class.
http://ws.apache.org/axis/java/apiDocs/org/apache/axis/message/MessageElement.html
You might also consider posting to and/or searching in the Axis user mailing list.
http://ws.apache.org/axis/mail.html
Please be aware I'm not a Java or Axis expert, but I hope this helps.
Copy link to clipboard
Copied
You have been very helpful. With your assistance, I have discovered that it returns an XML array. I was able to validate that with the IsArray function. Allow me to explain what I am going to do with the result set and let me know if you see any issues with it...
I am going to be creating a form where a customer can put in their customer number to submit to a web service. This web service will return the XML array. I will use the code below to convert the array to a list and then use a cfif statement to validate the result set of the list. Based upon that cfif outcome, I can then take action for the end user. Does this soound ok?
<cfset test = #ArrayToList(a_customerXMLResponseElement.get_any())#>
<cfif #test# CONTAINS "whatever_content_we_test_against">Yes<cfelse>No</cfif>
Thanks again.
Copy link to clipboard
Copied
Glad to have helped. In regards to your handling of the XML returned from the service; be careful using the ArrayToList function. A CF list is just a comma delimited string. If your data contains a comma you could get a list with more items in it then items in the array. In addition list functions such as ListLen ignore empty elements. If the XML array you mention is an XML document or contains an XML document you are probably better off using ColdFusion's built in XML functions.
Can you provide a sample of an XML array and the content you'd like to check for?
XML functions
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions-pt0_21.html#3468770
Using XML and WDDX
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=XML_01.html
Copy link to clipboard
Copied
Here is the XML that is returned...
<result>
<ROWSET>
<ROW num="1">
<CUSTOMER_NUMBER>019889</CUSTOMER_NUMBER>
<CUSTOMER>MOUNTAIN BUILDING SUPPLY, INC #8228</CUSTOMER>
<PLATFORM>500</PLATFORM>
</ROW>
</ROWSET>
</result>
What do you recommend?
Copy link to clipboard
Copied
I'd use Xpath via CF's XMLSearch function to search the result document and pull out the data you need. See a basic sample below. If this sample doesn't fit your needs please let me know.
For an overview of Xpath see http://msdn.microsoft.com/en-us/library/ms256115.aspx
<!--- sample data --->
<cfsavecontent variable="serviceResult">
<result>
<ROWSET>
<ROW num="1">
<CUSTOMER_NUMBER>019889</CUSTOMER_NUMBER>
<CUSTOMER>MOUNTAIN BUILDING SUPPLY, INC #8228</CUSTOMER>
<PLATFORM>500</PLATFORM>
</ROW>
</ROWSET>
</result>
</cfsavecontent>
<!--- use XML functions to parse and search serivceResult data --->
<!--- we expect the results from the service to be XML, but its always good to check --->
<cfif IsXml(serviceResult)>
<!--- create an XML object that CF's XML functions can use --->
<cfset xmlResult=XmlParse(serviceResult, true) />
<!--- check for a customer number of 019889, will return an array of matching objects
Note that second parameter for XmlSearch function is an Xpath expresssion
--->
<cfset customerSearch=XmlSearch(xmlResult, '/result/ROWSET/ROW/CUSTOMER_NUMBER[.="019889"]') />
<cfif ArrayLen(customerSearch) gt 0>
Customer found
<cfelse>
Customer not found
</cfif>
</cfif>
Copy link to clipboard
Copied
That works perfectly. Thanks a heap! This will help me on several projects I am working on. For example, I have another project where I am attempting to consume a .Net service and have been beating my head against a wall.
Copy link to clipboard
Copied
The book "Adobe ColdFusion 8 Advanced Application Development" by Ben Forta includes a code sample on converting a .NET web service dataset to a ColdFusion struct.
Copy link to clipboard
Copied
I might have to purchase that. UNfortunately, my company is on CF7. I am trying to get them to move forward.