SOAP、XML和HTTP三者的有何联系?

suncom_zhu 2002-01-31 12:40:27
请问各路高手,能否通过例程来说明SOAP、XML和HTTP三者的有何联系?
...全文
523 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
文山wenshan 2002-07-15
  • 打赏
  • 举报
回复
谢谢
zhangyancsdn 2002-04-01
  • 打赏
  • 举报
回复
SGML、XML和HTML的关系:HTML是SGML的一个应用,XML则是SGML的一个子集。





blueye 2002-04-01
  • 打赏
  • 举报
回复
很不错的东东,最好能拿出一个好而且有所有技术的的小例子,引领入门·!!!
lokaife 2002-03-31
  • 打赏
  • 举报
回复

关注!
suncom_zhu 2002-03-27
  • 打赏
  • 举报
回复
我是否要配一个SOAP服务器,若是,如何.....
david_ye 2002-03-02
  • 打赏
  • 举报
回复
Web Service ->Soap ->Xml->Http
szwxy 2002-03-02
  • 打赏
  • 举报
回复
收藏
suncom_zhu 2002-03-01
  • 打赏
  • 举报
回复
谢谢!
Justin 2002-02-26
  • 打赏
  • 举报
回复
什么是XML


正象HTML一样,可扩展置标语言XML(eXtensible Markup Language)也是一种置标语言。它同样依赖于描述一定规则的标签和能够读懂这些标签的应用处理工具来发挥它的强大功能。这一点,从XML的命名上也可窥见一斑。

“关于此规范的正确题目,亦即XML的正确全名,应该是Extensible Markup Language, eXtensible Markup Language只不过是一个拼写错误罢了。但是,现在简写XML不仅正确,而且正如它在本规范的标题中一样,是Extensible Markup Language的官方名称。
这个名称和简写是由James Clark最先提出的,其它可供选择的名称还包括小型标准置标语言MGML (Minimal Generalized Markup Language), 标准置标语言的小型结构MAGMA (Minimal Architecture For Generalized Markup Applications), 以及互联网置标结构语言SLIM (Structured Language for Internet Markup)。

——Extensible Markup Language (XML) 1.0 Specs, The Annotated Version. ”


从对XML的最初命名可以看出,XML的核心归根结底还是置标。不过,XML这个置标语言可比HTML的功能要强大的多了。

“人”如其名,XML的强大功能来自于“X”。也就是说,XML不但是置标语言,而且是可扩展的(eXtensible)置标语言。XML并非象HTML那样,提供了一组事先已经定义好了的标签,而是提供了一个标准,利用这个标准,你可以根据实际需要定义自己的新的置标语言,并为你的这个置标语言规定它特有的一套标签。准确的说,XML是一种源置标语言,它允许你根据它所提供的规则,制定各种各样的置标语言。这也正是XML语言制定之初的目标所在。

“XML的制定目标为:
XML应该可以在互联网上直接使用(*就象HTML那样好用)。
XML应该支持各种不同的应用方式(*不但包括浏览,还包括对内容的分析)。
XML应该与SGML兼容(*子承父业嘛,后面我们会讲到,SGML是XML的直接先驱)。
处理XML文件的应用程序应该容易编写(*计算机系的研究生花上两周的工夫就该差不多了)。
XML中的可选特性的数量应该减到最小,最好减至没有(*可选特性经常造成混淆)。
XML文件应该具有良好的可读性,并且比较清晰(*别象HTML那样,如果不借助浏览器,要想读它简直就是对你意志力和耐心的考验)。
用XML设计新的置标语言应该方便快捷(你不必再去经历标准制定的繁琐程序了)。
XML设计的置标语言应该正式、简洁(不然怎么易写易读?)。
XML文件应该容易编制(想想要用“记事本”写个HTML是一件多么可怕的工作)。
XML标记的简洁性并不重要(你不必再去费尽心机减少标记)。
——Extensible Markup Language (XML) 1.0 Specs, The Annotated Version.”



让我们来考虑一个非常简单的例子。如果我们需要定义一个新的置标语言,叫做FCLML(F_company s Client List Markup Language)——F公司的客户列表置标语言。这个语言应该定义一些标签来代表可联系的客户和有关他们的信息。这组标签很简单,它们的优点是代表了一定的语意。让我们回想一下上一节中这些信息在HTML中是如何用标签〈UL〉和〈LI〉表示的。与之相比,下面这一段代码,显然更加清晰易读:

<联系人列表>
<联系人>
<姓名>张三</姓名>
<ID>001</ID>
<公司>A公司</公司>
<EMAIL>zhang@aaa.com</EMAIL>
<电话>(010)62345678</电话>
<地址>
<街道>五街1234号</街道>
<城市>北京市</城市>
<省份>北京</省份>
<ZIP>100001</ZIP>
</地址>
</联系人>

<联系人>
<姓名>李四</姓名>
<ID>002</ID>
<公司>B公司</公司>
<EMAIL>li@bbb.org</EMAIL>
<电话>(021)87654321</电话>
<地址>
<街道>南京路9876号</街道>
<城市>上海</城市>
<省份>上海</省份>
<ZIP>200002</ZIP>
</地址>
</联系人>
</联系人列表>

这一段代码是一个非常简单的XML文件。看上去它和HTML非常相象,但细心的人会发现这里的标签代表的不再是显示格式,而是对于客户信息数据的语意解释。

事实上,用XML定义的置标语言可以根据标记描述的侧重点不同分为两大类。一类偏重于语意描述,正如上面这个例子。还有一类偏重于显示方式的描述,象现在已经出炉的XHTML、SVG、SMIL,后面我们还会详细讲解。值得一提的是,这里对于显示方式的描述不仅限于对文本的描述,还可以包括矢量图形、图象、声音。比如,一个形如〈EMPHASIZE〉的标签在描述文本时可能是要求将文本加粗,而在描述声音时则要求将音量加大。

不过,正如我们上节所述,仅仅将数据置标还不够。为了让别人读懂这些数据,置标语言中的置标标准还需包括:

置标的语法
每个置标的含义
换句话说,如果想让计算机应用程序读懂并能处理这段数据,它还必须知道什么是一个有效的置标(如标签),如何处理一个有效的置标。具体地说,Netscape浏览器如何知道怎样显示上面的这段XML文件?标签〈电话〉是什么含义?它究竟是不是一个合法的标签?它又应该以什么方式表现?因此,我们的置标语言必须能够告诉应用程序它所采用的置标的语法,以便于应用程序对其处理。

在XML中,置标的语法是通过文件类型定义DTD(Document Type Definition)来描述的。也就是说,我们通过DTD来描述什么是有效的标签,从而进一步定义置标语言的结构。在用XML定义的置标语言中,DTD与数据文件是分离的部分。第三章我们将详细讨论DTD的定义方法。这里我们先给出关于上例的DTD描述,让大家先睹为快:

fclml.dtd:
<?xml version="1.0" encoding="GB2312"?>

<!ELEMENT 联系人列表 (联系人)*>
<!ELEMENT 联系人 (姓名,ID,公司,EMAIL,电话,地址)>
<!ELEMENT 地址 (街道,城市,省份)>
<!ELEMENT 姓名 (#PCDATA)>
<!ELEMENT ID (#PCDATA)>
<!ELEMENT 公司 (#PCDATA)>
<!ELEMENT EMAIL (#PCDATA)>
<!ELEMENT 电话 (#PCDATA)>
<!ELEMENT 街道 (#PCDATA)>
<!ELEMENT 城市 (#PCDATA)>
<!ELEMENT 省份 (#PCDATA)>

同样,除了定义置标的语法外,我们还需定义置标的具体含义。为了明确各个标签的意义,XML使用与之相连的样式单(style sheet),由它来向应用程序,比如浏览器,提供如何处理显示的指示说明。一个样式单的具体格式我们在第四章再具体描述,现在我们只需知道,样式单所作的规定可能是这样的:

每当看到一个〈联系人〉标签,用一个〈UL〉标签显示它。同样,〈/联系人〉转换为一个〈/UL〉标签。
所有的〈姓名〉标签被转换为〈LI〉标签加以显示。同样,〈/姓名〉转换?LI〉标签。
所有的〈EMAIL〉标签被转换为〈LI〉标签加以显示。同样,〈/EMAIL〉转换为〈/LI〉标签。
等等...

在这个样式单的例子中,我们使用HTML的标签功能来定义我们的FCLML的显示格式。但如果XML文件不是由浏览器,而是由其它应用程序来进行处理,我们可能采用其它相应的标签。

于是乎,我们的应用处理程序要综合DTD,样式单以及FCLML文件数据三方面要素,根据这些数据和规定来显示它。

看到这里,你可能会长叹一声:这不是越来越复杂了吗?原先只要一个HTML就能把数据和显示方式都包括进去,现在我们需要FCLML文件,DTD,样式单——总共三个文件!这还不算,我们需要一个处理工具把DTD、样式单、FCLML三者合一。别忘了,浏览器只是用来处理一种特定的置标语言(比如HTML)的,而不是用来处理所有置标语言的。这说明我们不但要把三个文件合一,还要制作或购买一个新的应用处理程序。太恐怖了!

“一个被称作XML处理器的软件模型应该能够读入一个XML文件,并解释其内容和结构。XML处理器是基于另一个称作应用的模型来进行这种处理的。
——Extensible Markup Language (XML) 1.0 Specs, The Annotated Version”


的确,对于初学者而言,在使用XML时确实要克服一些障碍,不过在下面一节中,你将看到,这是非常值得的。


摘自http://www.xml.net.cn
thatwind 2002-01-31
  • 打赏
  • 举报
回复
HTTP
|
|协议
|
XML<----SOAP
基于
孟子E章 2002-01-31
  • 打赏
  • 举报
回复
You call Web services with messages that are written in the SOAP format. SOAP is a specification that defines the XML format for messages. A well-formed XML fragment enclosed in a couple of SOAP elements is a SOAP message. SOAP stands for Simple Object Access Protocol. You could print out a SOAP message, fax it to a remote location, and type it into the remote machine without violating the SOAP standard. More likely, you would send a SOAP message inside an HTTP message. There's no standard for how a SOAP message is carried, and SOAP doesn't care what the transport is. The SOAP specification defines what an HTTP message containing a SOAP message must look like.

The SOAP specification includes three major parts. The required part defines the structure of an XML document that can be used to exchange data between applications. Section 5 defines a way to encode programming language data types in XML. Such a message is called a section-5 encoded SOAP message. A regular message that contains an XML document is called a literal SOAP message. Section 7 of the SOAP definition is also optional. It deals with RPC (remote procedure calls), where the message is sent synchronously. You call a Web service's function and wait to check the return code. The default specification is for asynchronous call.
You can call Web services from JavaScript. In upcoming tips and columns we'll cover the motivation and the implementation of Web services, and how to use them from JavaScript.


Benefits of XML Web Services

Experts and visionaries believe that the benefits of XML Web services will be instrumental in propelling explosive business growth over the next few years. One of the major benefits is the Web services' ease of integration. You will easily integrate your software with other pieces of software. You can run on all kinds of machines, from the desktop to the mainframe, either within your enterprise or at external sites. This ease of integration will enable tighter business relationships and more efficient business processes.
With Web services readily available, and as the pool of XML Web services grows, you would be able to find software modules that can be integrated into your own application, by finding it and integrating it through XML Web services. Integrate with existing Web services instead of reinventing them. The bottom line is that you will be able to develop applications much faster than before.

An integral part of the XML Web services programming model, is the ease of integration with external data sources. No longer does each application need to copy and maintain external data sources. You can request and get information in real time, and transform it to your particular format. This will allow you to deliver individualized software and services, while your maintenance burden is reduced.

Consumers will enjoy ease of use when using XML Web services-based applications. XML Web services link applications, services, and devices together. Using Web services will be an integrated experience that excels in its simplicity. XML Web services give users the ability to act on information any time, any place, and from any smart device.

Businesses will love Web services because it will force them to streamline their processes. All suppliers will use the same language to describe their offerings. An XML Web service is a simple, reliable way to blend existing systems with new applications and services.

You can call Web services from JavaScript.
suncom_zhu 2002-01-31
  • 打赏
  • 举报
回复
多谢liuyanghr,但我是不明白在哪里传输这个请求?能否详细一点,因本人还是新手,望多多指点。
liuyanghr 2002-01-31
  • 打赏
  • 举报
回复

POST /StockQuote HTTP/1.1
Host: www.stockquoteserver.com
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn
SOAPAction: "http://example.org/2001/06/quotes"

<env:Envelope
xmlns:env="http://www.w3.org/2001/06/soap-envelope" >
<env:Header>
<t:Transaction
xmlns:t="http://example.org/2001/06/tx"
env:encodingStyle="http://www.w3.org/2001/06/soap-encoding"
env:mustUnderstand="1" >
5
</t:Transaction>
</env:Header>
<env:Body >
<m:GetLastTradePrice
env:encodingStyle="http://www.w3.org/2001/06/soap-encoding"
xmlns:m="http://example.org/2001/06/quotes" >
<m:symbol>DEF</m:symbol>
</m:GetLastTradePrice>
</env:Body>
</env:Envelope>

这是一个SOAP请求的例子,传输的方式是HTTP的POST,使用的语言为XML。
suncom_zhu 2002-01-31
  • 打赏
  • 举报
回复
没有人能帮上忙?!
suncom_zhu 2002-01-31
  • 打赏
  • 举报
回复
多谢。能否用一例程来说明?
karma 2002-01-31
  • 打赏
  • 举报
回复
SOAP is another protocol which runs above HTTP and whose data is XML

8,906

社区成员

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

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