Archive for category XML

Invoking a Webservice Using CFHTTP


I found this article by James Netherton on a discussion list of CF-Brasil group.

I needed that long time ago, when I had to import some data from a PHP web application. I tried his code and it works perfectly, so I’m linking to his blog so you may use that code too if you need.

Invoking a Webservice Using CFHTTP

Here is his code for the component:

<cfcomponent output="false" style="rpc">
<cffunction name="addNumbers" access="remote" returntype="numeric" output="false">
<cfargument name="firstNumber" type="string" required="true"/>
<cfargument name="secondNumber" type="string" required="true"/>
<cfreturn arguments.firstNumber + arguments.secondNumber/>
</cffunction>
</cfcomponent>

Here is his code for the test:

<!--- You'd need to strip any whitespace before passing to CFHTTP --->
<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:addNumbers soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://directorypath">
<firstNumber xsi:type="xsd:string">100</firstNumber>
<secondNumber xsi:type="xsd:string">10</secondNumber>
</ns1:addNumbers>
</soapenv:Body>
</soapenv:Envelope>
</cfsavecontent>
<!--- Note that there's no ?wsdl appendage to the url --->
<cfhttp url="http://myserver/webservice.cfc" method="post">
<cfhttpparam type="header" name="content-type" value="text/xml">
<cfhttpparam type="header" name="SOAPAction" value="">
<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>
<!--- Dump out a nice representation of the SOAP response --->
<cfdump var="#xmlParse(cfhttp.FileContent)#">
Bookmark and Share

Tags: , , , ,

Parsing Large XML File Into ColdFusion XML Object


Last week I had a big headache trying to import a 165MB XML file. I couldn’t even open it with any browse and reading it with ColdFusion gave me 500 errors, exceeded heap size, JRun closed connection, etc…

The solution I found was to read the file line-by-line using Java and creating blocks of XML code that allowed me to parse into objects and process them individually. Remembering, we use CF7 yet.

So I wrote this piece of code where I set my start tag and it will grab everything between my start and end tag, and assemble a XML object from there. I know the CF Gurus would suggest a much better solution, but that’s what i could accomplish with my humble knowledge and give a quick solution for the problem.
Read the rest of this entry »

Bookmark and Share

Tags: , , ,

Get Adobe Flash playerPlugin by wpburn.com wordpress themes