Integrating with CalcXML's calculators

This document is a quick tutorial to get you started with your integration of CalcXML's calculators. The following two methods will be discussed:
  1. xml via standard http
  2. web services

Shared Steps

These first two steps you must do regardless of whether you use xml via http or web services:
  1. You gather all the input fields for the calculator.
  2. You create an xml document containing all the input you gathered in step 1 as well as your CalcXML username and password.

XML Via Standard HTTP

After completing the first two steps as outlined above, you simply send your xml document as a parameter to the URL below. The name of the parameter must be "xmlInput".

http://www.calcxml.com/do/xmlHttpRequest

You can send your http request as either a GET or a POST. Here is a lengthy example of a GET:

http://www.calcxml.com/do/xmlHttpRequest?xmlInput=<?xml version="1.0" encoding="UTF-8" ?><calcxmlRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.calcxml.com/schema/1.3/calcxmlRequest.xsd" username="guest" password="water" responseType="both" version="1.3"><xyChart><chartTitle>Chart Title</chartTitle><threeD>1</threeD><barColor>6D9D6D</barColor><barColor>CD3B3B</barColor><barColor>8C93A5</barColor><chartWidth>400</chartWidth><chartHeight>300</chartHeight></xyChart><dataTable><cssClassName>simpletable</cssClassName></dataTable><calcInput includeInResponse="true"><det03><loanAmount>5000</loanAmount><interestRate>0.05</interestRate><termMonths>60</termMonths><amortization>1</amortization></det03></calcInput></calcxmlRequest>

You can try it out by clicking here or pasting the above example into a browser address bar and click Enter. You'll receive an XML document in response. The final step is to retrieve the results from the xml document and display them in your result page.

Security Note: In practice, you will not want to create the above xml document on the client-side, since it contains your CalcXML username and password.

Web Services

If you choose to integrate using web services, then there are two additional steps involved:
  1. You call the desired calculator via a web service method call.
  2. Retrieve the results from the returned xml document and display the results to the user.
JavaDocs
http://www.calcxml.com/doc/index.html

Some XML Schema Files
http://www.calcxml.com/schema/1.3/calcxmlRequest.xsd
http://www.calcxml.com/schema/1.3/calcxmlResponse.xsd
http://www.calcxml.com/schema/1.3/dataTable.xsd
http://www.calcxml.com/schema/1.3/pieChart.xsd
http://www.calcxml.com/schema/1.3/xyChart.xsd
http://www.calcxml.com/schema/1.3/types.xsd

Sample Java Code
http://www.calcxml.com/documentation/Det02.jsp is a sample input page.
http://www.calcxml.com/documentation/Det02Action.java shows the creation of the xml input and calling the calculator service. It also shows the parsing of the xml response document and the setting of the UI components for display.

You can see these files in action here:
http://www.calcxml.com/do/det02