如何结合isapi、xml和xsl来做web服务程序

tlovexyj 2001-12-10 11:14:36
加精
用VC做ISAPI,小弟用ODBC API将数据库中提取出的数据根据美工做的模板生成html
可是为了今后的扩展性和可维护性,小弟突发一想,isapi只将数据生成xml写回页面,将其数据和显示(原来是html,用的是CHttpServer)分离,以外部的xsl负责显示,这样在程序dll不必改,只用改xsl即可。
不知可否实现,请诸位大侠提示(详)
...全文
186 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
tlovexyj 2001-12-13
  • 打赏
  • 举报
回复
up~
karma 2001-12-12
  • 打赏
  • 举报
回复
sorry, my email account has been bombarded by sick people with virus-infected emails lately , I do not want to reveal my email account in public
tlovexyj 2001-12-12
  • 打赏
  • 举报
回复
o i am sorry about that~
i just want to ... ... hehe, forget that~
karma 2001-12-11
  • 打赏
  • 举报
回复
if you are developing intranet applications, then normally the client machines are powerful, sending data to the client and processing data there is not a problem

if your xml data is dynamic and you are developing applications for users with diverse machine capabilities, then you have no choice but do the transformation on the server
tlovexyj 2001-12-11
  • 打赏
  • 举报
回复
谢谢无为兄。
我想比较实用一点的就数c和d了。而xsl最好单个xml对应,放在外面。
在c中,server端轻松了(只用做1读数据2生成xml),但是如果数据一大堆,传给client端的html中一大块xml island,不爽而且不安全。
在d中,server端要每个client访问都需要用dom来transformation xml,这样负荷要成倍增长。
tlovexyj 2001-12-11
  • 打赏
  • 举报
回复
2 无为:
i choose 2 for me, 3x for ur answer.
i will try it in my developing application, 3x again~
can u give me ur email? 3x~
karma 2001-12-10
  • 打赏
  • 举报
回复
you can write both XML and XSLT as XML islands and then do transformation in onload event, like this
1.
<xml id="xmldoc">
....
</xml>

<xml id="xsldoc">
....
</xml>
<div id="dv"></div>
<script language="javascript">
function window.onload()
{
document.all("dv").innerHTML = xmldoc.transformNode(xsldoc);
}
</script>

or
2.
<xml id="xmldoc">
....
</xml>

<xml id="xsldoc" src="somexslt.xsl"></xml>
<div id="dv"></div>
<script language="javascript">
function window.onload()
{
document.all("dv").innerHTML = xmldoc.transformNode(xsldoc);
}
</script>
tlovexyj 2001-12-10
  • 打赏
  • 举报
回复
我试过了,直接写回xml的数据岛,由于父类是CHttpServer,所以并不能解释并显示出xml
2 无为:
偶知道您是大虾,您说的那个东东俺懂,可是并不是那样就可以的。目前是server应该用哪个,反正CHttpServer是不行的,它对应的是html。而在isapi中,vc的wizard自动建立的就是CHttpServer的一个子类。xml有一个ServerXMLHTTP,我想问的是:结合isapi该如何使用?再有就是xml内容可以直接由类似"select * from 院系基本信息 for xml auto,ELEMENTS"这样的sql语句得到xml数据岛,这样就不用我们自己生成了(如果有特殊需要还是要的)。现在是如何显示的问题。

偶查了查原来的资料,发现还可以这样实现:
<html>
<head>
<script language="JavaScript" for="window" event="onload">
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.load("xmlData/xmlzhgs.asp");

var xslDoc = new ActiveXObject("Microsoft.XMLDOM");
xslDoc.async="false";
xslDoc.load("xslData/zhgs.xsl");

idXML.innerHTML = xmlDoc.transformNode(xslDoc);

function layerShow(strID){
node = xmlDoc.selectSingleNode("//row[@id="+strID+"]");
alert(strID);
while (true){
node = node.nextSibling;
myID = node.getAttribute("id");
if (myID.substr(0,strID.length) == strID){
if (node.getAttribute("show") == "T")
node.setAttribute("show","F");
else
node.setAttribute("show","T");
}
else
break;
}
idXML.innerHTML = xmlDoc.transformNode(xslDoc);
return true;
}
</script>

<title>XML数据库</title>
<LINK rel="stylesheet" type="text/css" href="style5.css">
</head>
<body bgcolor="#FFFFFF">
<div id="idXML"></div>
</body>
</html>

不知道地道否,希望大家一起讨论一下。!!!!!
karma 2001-12-10
  • 打赏
  • 举报
回复
sure, add
<?xml-stylesheet type="text/xsl" href="whatever.xsl" ?> to your XML file, following
<?xml version="1.0" ?>
karma 2001-12-10
  • 打赏
  • 举报
回复
1. "想问问,对比CHttpServer和CHtmlStream,XML有无对应或相关class可代替之? "
you can download MSXML3 SDK or MSXML4 SDK and use classes in them

2. "目前这是否是最地道的解决办法呢"?
these are the normal methods to do XSLT transformation:
a. output xml directly (with an xml-stylesheet pi) and have the browser take care of the transformation
b. embed xml/xsl island inside the pages and do the transformation on the client side using javascript
c. dynamically load xml/xslt and do the transformation on the client side using javascript
d. do the transformation on the server side
tlovexyj 2001-12-10
  • 打赏
  • 举报
回复
还有一个想法,就是:
同样实现一个想法,但是所应用的方法"地道"于否,是否应该考虑一下呢?
目前这是否是最地道的解决办法呢?
qick and dirty?
hehe
tlovexyj 2001-12-10
  • 打赏
  • 举报
回复
2 无为:
谢谢,
小弟觉得第2种方法比较好。
俺去试试看。
想问问,对比CHttpServer和CHtmlStream,XML有无对应或相关class可代替之?
源码8 IDOMDocument vs. IXMLDocument.... . 8 TXMLDocument Programming .... 9 XML TreeView .. 12 TXMLDocument as Windows Service........................................... 14 XML Data Binding .............................................................................. 16 Generated Code ...................................................................... 20 Delphi XML Mapper............................................................................ 23 The XML Mapping Tool.............................................................. 23 Selecting Nodes ...................................................................... 24 Create and Test Transformation................................................. 26 XMLTransform......................................................................... 28 Visual Transformation .............................................................. 30 TXMLTransformClient ............................................................... 31 XSLT ............................................................................................... 32 XSL Transformations................................................................ 32 MSXSL ................................................................................... 32 Some examples of XSLT.................................................... 32 Default XSLT Templates ........................................................... 34 Our own XSLT Processor........................................................... 35 XML and XSL .......................................................................... 35 XMLData property ............................................................ 35 FileName property............................................................ 35 XML property................................................................... 36 XSLT Processor ....................................................................... 37 Alternative Approach ........................................................ 37 Summary......................................................................................... 38 2. Web Services: SOAP & WSDL 39 Web Services.................................................................................... 39 SOAP..................................................................................... 39 WSDL .................................................................................... 39 XSD Data Types ...................................................................... 41 SOAP and XML ........................................................................ 41 Building Delphi for Win32 Web Services................................................ 42 Debug and ISAPI..................................................................... 43 Second target (Indy) ........................................................ 44 SOAP Web Module............................................................ 45 SOAP Server Interface ............................................................. 47 SOAP Server Implementation .................................................... 51 Indy VCL Project ............................................................................... 53 Consuming Web Services.................................................................... 55 SOAP Client ............................................................................ 56 Using GetIEcho ....................................................................... 60 Delphi XML, SOAP & Web Services Bob Swart Training & Consultancy - iii - www.drbob42.com Using THTTPRIO...................................................................... 64 WSDL vs. SOAP....................................................................... 65 AdminEnabled......................................................................... 66 GetIEcho Implementation ......................................................... 69 Conversion Web Services.................................................................... 70 TemperatureIntf...................................................................... 72 TemperatureImpl .................................................................... 72 Debugging Web Services .................................................................... 73 Web Service Client................................................................... 73 Server Breakpoints .................................................................. 74 Deployment on Windows Server 2003 and IIS ....................................... 75 Enabling ISAPI / CGI................................................................ 75 Virtual Directory ...................................................................... 76 SSL Certificates................................................................................. 79 SSL and IIS6 on Windows Server 2003....................................... 79 Installing SSL Certificates ......................................................... 82 Deployment on Windows Server 2008 and IIS7 ........................... 83 Tracing Web Services......................................................................... 88 SOAP and Exceptions ......................................................................... 89 Echo Interface unit .................................................................. 89 Echo implementation unit ......................................................... 89 Echo import unit...................................................................... 90 Extending SOAP Exceptions....................................................... 90 SOAP and Databases ......................................................................... 92 Database Client....................................................................... 94 Extra Data Module ................................................................... 96 Alternative to data module: web module..................................... 98 SOAP Attachments ............................................................................ 98 Receiving SOAP Attachments .................................................... 101 Summary......................................................................................... 103 Exercises.......................................................................................... 103 Exercise #1 ............................................................................ 103 Exercise #2 ............................................................................ 103 Exercise #3 ............................................................................ 103 Exercise #4 ............................................................................ 103 Exercise #5 ............................................................................ 103 Exercise #6 ............................................................................ 103 Exercise #7 ............................................................................ 103 Exercise #8 ............................................................................ 103 3. SOAP and Security 105 SSL Certificates................................................................................. 105 Web Service Example......................................................................... 105 SourceCodeIntf................................................................ 105 SourceCodeImpl .............................................................. 106 Importing Win32 Secure Web Service ................................. 107 Summary......................................................................................... 108 Exercises.......................................................................................... 108 Exercise #1 ............................................................................ 108 Exercise #2 ............................................................................ 108 Exercise #3 ............................................................................ 108 4. Case Study: Automatic Updates 109
X3-BLOG 是基于XML+XSLT+AJAX技术构建的开源多用户博客门户系统,服务器端采用当前最流行的动态网页开发语言之一ASP.NET(C#) 2.0编写,支持多种数据库,包括SQLSERVER2000\SQLSERVER2005\ORACLE\MYSQL\DB2\ACCESS等,默认使用SQLSERVER2000。 X3-BLOG 遵从 GENERAL PUBLIC LICENSE(GPL) 开源协议,这意味着可以修改程序的一个或几个副本或程式的任何部分,以此形成基於这些程式的衍生作品。必须在修改过的档案中附有明显的说明:您修改了此一档案及任何修改的日期。 您必须让您发布或出版的作品,包括本程式的全部或一部分,或内含本程式的全部或部分所衍生的作品,允许第三方在此许可证条款下使用,并且不得因为此项授权行为而收费。 功能与特点 X3-BLOG完美的利用了浏览器的XML解析技术,完全实现数据和界面的分离,使网络传输数据量大大减少,加载速度远远超过了市面上所有的BLOG产品,有效的减轻了服务器的带宽压力,服务器端使用四大动态网站开发语言中速度最快的ASP.NET(C#)编写,屏弃了传统的控件开发方式,所有执行过程采用单向流的生成方式,使其对服务器CPU及内存资源的占用降至最低水平,并通过gzip压缩进一步缩减服务器的网络带宽消耗,提高响应速度 。 无Session设计杜绝了用户会话无故丢失的尴尬,客户端关联的会话加密方式带来了用户数据的高安全性,独特的XSL结构设计,彻底消除了跨站脚本攻击的隐患,杜绝恶意代码的执行,同时保证了文章内容的完整性。 DIV+CSS布局,交互方式采用当前最流行的AJAX技术,所有操所在一个页面完成,并实现了AJAX的最高应用——AjaxUpload,所有操作一气呵成,带来前所未有的用户体验。 简洁的主题与皮肤开发技术,更合理的模块化设计,大大减轻了后续开发的难度,使模板开发变得轻而易举。 自主研发的中文分词技术,速度超过3MB/s,准确率达到90%以上,大大超过网上各种开源中文分词技术,几乎可以和中科院的ICTCLAS相媲美,结合当前最成熟的Lucene的.net版本,实现了功能强大执行快速的全文检索引擎。 兼容性 Mozilla Firefox v1.5.0.0 以上版本 Microsoft Internet Explorer v6.0 以上版本 开发者 水月·静夜思 website: http://www.x3blog.cn QQ群: 39687684 编译与安装 1.用Microsoft Visual Studio 2005打开src中的SyCODE.x3-blog.sln并执行发布。 2.创建IIS站点,路径指向发布目录,并将ASP.NET版本设置为2.0。 3.进入站点属性设置,设置默认文档为main.xml、head.jpg、head.gif和head.png。 4.设置ISAPI筛选器,创建名为URLRewrite的筛选器,执行文件指向压缩包中URLRewrite目录下的Rewrite.dll,httpd.ini文件必须和Rewrite.dll放在相同录中。 5.为发布目录设置IIS和ASP.NET用户的读写权限。 6.启动SQLServer查询分析器,执行database目录中X3BolgData.sql创建数据库。 7.创建SQL用户并支派其对数据库X3-BLOG的相关权限。 8.启动站点根路径下的stringcrypt.htm,根据实际情况输入数据库连接字符串,点击加密按钮,复制加密后的密文,替换网站根目录下的数据源配置文件DataSource.config的根节点中的connstring属性。 9.解压复制SyCODE.ThesaurusAnalysis项目中的Dicts下的所有文件至任意目录。 10.打开站点根目录下的web.config文件,找到smtpSettings节点,按照提示设置相应节点属性。使用stringcrypt.htm页面加密邮箱密码添入password属性中。 11.找到web.config中的appSettings配置节点,将IndexDirectory设置成保存日志索引的真实目录路径,将StoreDirectory设置成保存日志正文压缩文档的真实目录路径,将DictsDirectory设置为第8步中选择的存放目录。 12.打开host.xml文件,将host和searchhost节点的内容改为你实际的站点路径。

8,907

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧