11.07.2015 Views

webMathematica™ Wolfram - Wolfram Research

webMathematica™ Wolfram - Wolfram Research

webMathematica™ Wolfram - Wolfram Research

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

esult = With[{var = Symbol["x"]}, Plot[e, {var, 0, limit}]];SchemaBase64Binary[ToCharacterCode[ExportString[result, "GIF"]]]]ServiceReturn[PlotString] = _SchemaBase64Binary142 webMathematica User GuideEnd[]EndPackage[]One important detail here is how the implementation uses MSPToExpression to convert thestring input into a Mathematica expression. This is necessary for security. If the service isinvoked with an input that does not pass the security test, a failure results.In[7]:=res = PlotString@ "ReadList@xD", 10DOut[7]= $FailedInvokeServiceOperation::rspnsflt : SOAPFault occurred: ServiceException@SecurityErrorD àOne of the advantages of using SOAP is that it has standards for how error conditions should behandled and reported. Any client toolkit can support these errors, which takes the burden awayfrom the developer.Excel ExampleThis example demonstrates how to call a Mathematica web service from Excel. The Mathematicacode is Integrator.m, and the source can be found in the webMathematica web applicationin the directory Examples/WebServices/Plot.m (the full path in Tomcat would be webapps/webMathematica/Examples/WebServices/Plot.m). The Excel spreadsheet file, WebServicesExÖample.xls, can be found in the Extras directory in your webMathematica distribution.This shows the implementation of the Integrator web service.BeginPackage["IntegrateService`", {"WebServicesServer`", "MSP`"}]IntegrateString::usage = "Integrates an equation with respect to x.The function is passed in as an InputForm string and the result is anInputForm string."Begin["`Private`"]IntegrateString[str_String] :=Module[{e, result},e = MSPToExpression[str];result = Integrate[e, Symbol["x"]];ToString[result, InputForm]]ServiceReturn[IntegrateString] = _StringEnd[]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!