|
XML Web Service-Enabled Office Documents本文关键字 理论探讨 广告 XML Web Service-Enabled Office Documents
March 19, 2001 Download or browse the xml03192001.exe in the MSDN Online Code Center. Are you ready for a marriage of Microsoft Office XP and .NET Web Services? In a networked world of B2B e-commerce, why not deliver the power of Web Services to the end user by integrating business process workflow right into everything people do from their desktop? What am I talking about? Well, an Excel spreadsheet that looks something like Figure 1. Figure 1. Web Services-enabled Excel spreadsheet This is not just an ordinary spreadsheet. It uses UDDI to find company addresses and it uses a Catalog Web Service to find product information. It also does an XML transform on the XML spreadsheet format to generate a RosettaNet PIP 3 A4 Purchase Order Request format when you click the Send button. When you type in the name of the company you are purchasing from, and then click on the Find button, some VBA code behind the spreadsheet makes a UDDI call and fills out the rest of the address section. For example, type in Microsoft, click Find, and you should see the following in the Purchase From fields: Figure 2. Purchase From field When you type in a quantity of, say, 23, and then the term Pear in the description field, then press the TAB key, some VBA code queries a SOAP Catalog Web Service to see if it can find a matching product, then it fills out the details. In this case, I have wired the Catalog Web Service to the Northwind database, so it returns the following: Figure 3. Detailed look at the order portion of the spreadsheet In this case, it has also filled out the description and turned it into a link which takes you to an HTML page that tells you all about that product. If more than one product is found and none of them matches exactly to what you typed, then a drop down list of choices is provided. For example, if you type tofu, you'll see the following choices: Figure 4. Example of multiple choices provided when an exact match is not found When you select one of these choices, then the specific details are provided. When you're done, you click the Send button and the RosettaNet PIP 3 A4 XML Purchase Order format is generated, and the order is sent. How Does All This Work? How the UDDI find_business call works can be found in my earlier article UDDI: An XML Web Service. If a business is found, the addressLines found in the /businessInfo/contacts/contact/address/ part of the UDDI response are used to populate the Purchase From address block. Catalog Web Service The Catalog Web Service is very simple. The .aspx entry point simply creates a CatalogSearch object which is defined in search.cs and calls Execute, passing the HttpResponse output stream as follows: <%@Language="C#" src="search.cs"
Debug="true" %> The Execute method is where the fun begins. This is very simple SQL Managed Provider code wrapped in an XmlTextWriter that returns the specific fields from the SQL SELECT statement. So it is basically a while loop through the DataReader, writing to the XmlTextWriter as follows: public void Execute(TextWriter
stm) The URL http://localhost/catalog/search.aspx?term=tofu returns the following result: <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> This is about the most efficient way you can get XML out of SQL Server using the .NET frameworks. With a very rough measurement, I got about 80 to 90 of these per second on my Dell PowerEdge 2400. Send Button With ActiveSheet This returns a huge chunk of XML that fully describes everything about that range of cells in the spreadsheet. The following is a snippet from the chunk of XML: <Workbook> Then we use XSL to turn this into the following format: <PurchaseOrder xmlns="http://www.rosettanet.org"> Note This is probably not a technically complete
Request according to RosettaNet PIP 3 A4 Purchase Order Request specification,
but you get the idea. select="/Workbook/Worksheet/Table/Row/Cell[NamedCell[@ss:Name='City']] This particular expression finds the Cell that is Named with the name City. The rest of the stylesheet is pretty straight forward. See XLToPO.xsl for additional information. Try It Out SQLConnection("server=localhost;uid=sa;pwd=;database=northwind"); You may need to change this bit of code if your Northwind database is elsewhere. The PO.xsl spreadsheet is expecting the Catalog Service to be located at: http://localhost/catalog/search.aspx You will need to install the Web Service search.aspx, search.cs, and XLToPO.xsl in a virtual directory called catalog on your local machine, or change the spreadsheet to point elsewhere. To edit the spreadsheet you will have to turn off protection, which can be done using the Tools/Protection submenu. Next Steps It would be a fun exercise to make use of Office Smart Tags to do similar things. See the Smart Tags SDK on http://msdn.microsoft.com/office/ for some additional information. 如果您希望与本文章的作者或其所在机构,进一步交流,请联系:畅享网 姜小姐 jill.jiang@amteam.org | 021-51096826-112 | 在线联系 |
前沿论丛2009年第三期——知识管理..国内中小企业普遍存在管理基础薄弱、规范化程度低、信息化基础差等方面的问题,而知识管理的实施难度甚至要高于ERP的实施,因为简单的从上而下压迫式的推行只能做到知识…… |
|
|