XMethods Query Web Service

This example demonstrates the XMethods Query Service.  XMethods.com is a web site that lists web services.  This example demonstrates using the XMethods Query Service to discover and use many of the web services available.  This example searches the XMethods database for the web services registered.  The example code then places the results in the notebook.  An InstallService function is placed in each of the Cells created for each service.  Once the query is finished, a user can conveniently browse through the services and install the services that may be interesting.  If GetServiceSummaries is called again, the code will match service id's with cell tags.  If an id exists as a cell tag no new cells will be added.  If an id does not exist the appropriate cells are added for the service.

To try this example, evaluate all the initialization cells (you can do this with the menu command Evaluation ▶ Evaluate Initialization Cells). Then go to the Example section.

Code

BeginPackage["WebServices`Examples`XMethods`",{"WebServices`","JLink`"}];

GetServiceSummaries;

Begin["`Private`"];

InstallService["http://www.xmethods.net/wsdl/query.wsdl"];

GetServiceSummaries[]:=Module[{result},result=getAllServiceSummaries[];
If[result===$Failed,Return[$Failed]];
notebook=EvaluationNotebook[];
If[NotebookFind[notebook,"Results",All,{CellTags}]===$Failed,SelectionMove[notebook,After,EvaluationCell];
NotebookWrite[notebook,Cell["Results","Section",CellTags->{"Results"}]];];
printResult/@result;
NotebookFind[notebook,"Results",All,{CellTags}];]

printResult[result_List]:=Module[{name,id,shortDescription,wsdlURL,publisherID},name="name"/.result;
id="id"/.result;
shortDescription="shortDescription"/.result;
wsdlURL="wsdlURL"/.result;
publisherID="publisherID"/.result;
notebook=EvaluationNotebook[];
If[NotebookFind[notebook,id,All,{CellTags},AutoScroll->False]===$Failed,NotebookFind[notebook,"Results",All,{CellTags},AutoScroll->False];
SelectionMove[notebook,After,Cell,AutoScroll->False];
NotebookWrite[notebook,Cell[CellGroupData[{Cell[BoxData[RowBox[{name,StyleBox[" from ",FontWeight->"Plain"],StyleBox[publisherID,FontWeight->"Plain",FontSlant->"Italic"],ButtonBox["(wsdl)",ButtonData->{URL[wsdlURL],None},ButtonStyle->"Hyperlink"]}]],"Subsection",ShowGroupOpenCloseIcon->True,CellDingbat->None,CellTags->{id}],Cell[shortDescription,"Text",ShowCellBracket->False,CellMargins->{{55,Inherited},{Inherited,Inherited}},CellFrame->True,Background->GrayLevel[0.850004]],Cell[BoxData[RowBox[{"InstallService[\""<>wsdlURL<>"\"]"}]],"Input",ShowCellBracket->False,CellFrame->True,CellMargins->{{55,Inherited},{Inherited,Inherited}},Background->GrayLevel[0.850004]]},Open]]];];]

End[];
EndPackage[];

Example

GetServiceSummaries[]