<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Open your thoughts &#187; XML</title>
	<atom:link href="http://blog.baturu.com/index.php/tag/xml/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.baturu.com</link>
	<description>James Gosling is not on the Java road any more !</description>
	<lastBuildDate>Fri, 20 Aug 2010 02:33:20 +0000</lastBuildDate>
	<language>zh-cn</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type='text/javascript' src='http://blog.baturu.com/wp-includes/js/jquery/jquery.js?ver=1.4.2'></script>
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
	<item>
		<title>定制 xmlbeans 所生成的 package</title>
		<link>http://blog.baturu.com/index.php/2010/08/15/customize_java_packages_generated_by_xmlbeans.html</link>
		<comments>http://blog.baturu.com/index.php/2010/08/15/customize_java_packages_generated_by_xmlbeans.html#comments</comments>
		<pubDate>Sun, 15 Aug 2010 09:29:14 +0000</pubDate>
		<dc:creator>javafuns</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://blog.baturu.com/?p=1258</guid>
		<description><![CDATA[xmlbeans 也是 XML binding 工具之一，不了解的同学可以去了解一下，是这方面比较流行的框架之一。本篇不会长篇累牍的去介绍如何使用，相信在这方面，官方文档已足够。
我们知道，xmlbeans 提供了命令行工具，同时也有 ant task，支持把 xsd 生成 Java class 这一功能。xmlbeans 所生成的这些 classes 的 package 其实是有一定规律的。默认情况下，package 是根据 namespace 和元素类型而定。在某些情况下，特别是这个 xsd 并不是我们所能控制的情形下，我们需要生成不同于 namespace 的 package，这时就需要我们做出一些特殊处理。]]></description>
			<content:encoded><![CDATA[<p>xmlbeans 也是 XML binding 工具之一，不了解的同学可以去了解一下，是这方面比较流行的框架之一。本篇不会长篇累牍的去介绍如何使用，相信在这方面，官方文档已足够。</p>
<p>我们知道，xmlbeans 提供了命令行工具，同时也有 ant task，支持把 xsd 生成 Java class 这一功能。xmlbeans 所生成的这些 classes 的 package 其实是有一定规律的。默认情况下，package 是根据 namespace 和元素类型而定。在某些情况下，特别是这个 xsd 并不是我们所能控制的情形下，我们需要生成不同于 namespace 的 package，这时就需要我们做出一些特殊处理。</p>
<p>命令行：<code>scomp -d ..\classes -src ..\src -javasource 1.5 EasyPO.xsd po.xsdconfig</code></p>
<p>ant task：﻿</p>
<pre name="code" class="xml">
<taskdef name="xmlbeans" classname="org.apache.xmlbeans.impl.tool.XMLBean" classpathref="project.class.path"/>
<xmlbeans schema="${basedir}/EasyPO.xsd" destfile="${basedir}/po.jar"
                 classpathref="project.class.path" javasource="6"
                 failonerror="false" quiet="true">
</xmlbeans>
</pre>
<p>注意，在 ant task 下，只需要把 po.xsdconfig 放在与 EasyPO.xsd 同一目录即可。</p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>2009/03/01 -- <a href="http://blog.baturu.com/index.php/2009/03/01/how-to-validate-xml-in-java-applications.html" title="Java 程序中如何对 XML 文档进行验证？">Java 程序中如何对 XML 文档进行验证？</a></li><li>2009/07/23 -- <a href="http://blog.baturu.com/index.php/2009/07/23/whats_the_purpose_of_schemalocation_attribute_in_xml.html" title="XML 中的 schemaLocation 属性究竟是什么意思？">XML 中的 schemaLocation 属性究竟是什么意思？</a></li><li>2009/07/07 -- <a href="http://blog.baturu.com/index.php/2009/07/07/which-style-of-wsdl-should-i-use-reship.html" title="Which style of WSDL should I use? (reship)">Which style of WSDL should I use? (reship)</a></li><li>2009/05/15 -- <a href="http://blog.baturu.com/index.php/2009/05/15/assign_default_schema_for_db2_in_hibernate.html" title="HIBERNATE－为DB2指定默认schema">HIBERNATE－为DB2指定默认schema</a></li><li>2009/03/02 -- <a href="http://blog.baturu.com/index.php/2009/03/02/whats-usage-of-xml-standalone.html" title="关于 XML standalone 的解释">关于 XML standalone 的解释</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.baturu.com/index.php/2010/08/15/customize_java_packages_generated_by_xmlbeans.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A brief introduction of what is RDF</title>
		<link>http://blog.baturu.com/index.php/2010/08/04/a_brief_introduction_of_whats_rdf.html</link>
		<comments>http://blog.baturu.com/index.php/2010/08/04/a_brief_introduction_of_whats_rdf.html#comments</comments>
		<pubDate>Wed, 04 Aug 2010 06:25:22 +0000</pubDate>
		<dc:creator>javafuns</dc:creator>
				<category><![CDATA[HTTP / WEB]]></category>
		<category><![CDATA[RDF]]></category>
		<category><![CDATA[SemanticWeb]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://blog.baturu.com/?p=1235</guid>
		<description><![CDATA[The Resource Description Framework (RDF) is a language for representing information about resources in the World Wide Web. It provides a graph structure for making statements about things. RDF is designed to be read and understood by computers. It is not designed to be displayed to people. RDF is the W3C standard for encoding knowledge. It is a specification that fills a particular niche for decentralized, distributed knowledge and provides a framework to enable computer applications to handle data.]]></description>
			<content:encoded><![CDATA[<p>The <strong>Resource Description Framework (RDF)</strong> is a language for representing information about resources in the World Wide Web. It provides a graph structure for making statements about things. RDF is designed to be read and understood by computers. It is not designed to be displayed to people. RDF is the <a href="http://www.w3.org/Consortium/">W3C</a> standard for encoding knowledge. It is a specification that fills a particular niche for <a href="http://ontotext.com/factforge/distribknowledge.html">decentralized, distributed knowledge</a> and provides a framework to enable computer applications to handle data.</p>
<p>RDF was <a href="http://www.w3.org/TR/1999/REC-rdf-syntax-19990222/">originally</a> created in 1999 as a standard on top of <a href="http://en.wikipedia.org/wiki/XML">XML</a> for encoding <a href="http://ontotext.com/factforge/metadata.html">metadata</a>, e.g. data about data. It is a foundation for processing metadata.</p>
<p>RDF specifies the data model and syntax for sharing knowledge about concepts on the Web. It does not specify how concepts may relate to one another.</p>
<p>RDF has a simple data model, based on triples:</p>
<p><em>subject</em> <em>predicate</em> <em>object</em></p>
<p>It is a graph-based formalism for representing metadata, where the subject and the object are things (entities), and the predicate denotes the relationship between them. Each triple represents a fact. The figure below shows <em>Peter</em> to be the subject of the triple, <em>Sofia</em> to be the object, and <em>lives in</em>to be the predicate describing the relationship between <em>Peter</em>, the subject, and <em>Sofia</em>, the object of the triple.</p>
<div id="attachment_1236" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.baturu.com/wp-content/uploads/2010/08/rdf-triple.jpg"><img class="size-medium wp-image-1236" title="RDF triple" src="http://blog.baturu.com/wp-content/uploads/2010/08/rdf-triple-300x45.jpg" alt="RDF triple" width="300" height="45" /></a><p class="wp-caption-text">RDF triple</p></div>
<p>The subject and object are nodes and the predicate (e.g. the property) &#8211; an arc. Properties are represented as a directed arc, so they are only valid from subject to object.<span id="more-1235"></span></p>
<p>RDF statements form a graph by being able to share subjects and objects. Also, the subject of one statement can be the object of another and vice versa. For instance, the figure below shows <em>Sofia</em> to be the object of the triple <em>Peter lives in Sofia</em> and the subject of the triple <em>Sofia located in Bulgaria</em>, and <em>Peter</em> to be the subject of both triples: <em>Peter lives in Sofia</em> and <em>Peter has website www.peter.com</em>.</p>
<div id="attachment_1240" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.baturu.com/wp-content/uploads/2010/08/rdf-subject-object.jpeg"><img class="size-medium wp-image-1240" title="RDF Graph" src="http://blog.baturu.com/wp-content/uploads/2010/08/rdf-subject-object-300x120.jpg" alt="RDF Graph" width="300" height="120" /></a><p class="wp-caption-text">RDF Graph</p></div>
<p>Each subject, predicate and object can have a name, a <a href="http://ontotext.com/factforge/uri.html">URI</a>. In the RDF model, these values are called RDF resources. So, an RDF triple really looks like this:</p>
<table border="1">
<tbody>
<tr>
<td><strong>Subject</strong></td>
<td><strong>Predicate</strong></td>
<td><strong>Object</strong></td>
</tr>
<tr>
<td><code>http://www.anon.com/foaf#Peter</code></td>
<td>http://www.location.org/rdf#lives_in</td>
<td><code>http://www.dbpedia.org/resource/Sofia</code></td>
</tr>
</tbody>
</table>
<p>Each resource is uniquely identified on the Web.</p>
<p>RDF graphs can be represented in <a href="http://www.w3.org/XML/">XML</a>. This is the RDF/XML syntax. XML encoding allows the graphs to be exchanged on the web. The example below shows the representation of the triple <em>Peter lives in Sofia</em> in RDF/XML.</p>
<p><code>&lt;rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"<br />
xmlns:ex="http://www.location.org/"<br />
&lt;rdf:Description rdf:about="http://www.anon.com/foaf#Peter"&gt;<br />
&lt;ex:lives_in&gt;<br />
&lt;ex:location rdf:resource="http://www.dbpedia.org/resource/Sofia" /&gt;<br />
&lt;/ex:lives_in&gt;<br />
&lt;/rdf:Description&gt;<br />
&lt;/rdf:RDF&gt;</code></p>
<p>RDF provides a model for making <a href="http://ontotext.com/factforge/logicalstatement.html">logical statements</a> which could be used for <a href="http://ontotext.com/factforge/definference.html">inference</a> tasks. It is aligned to the Web architecture and is simple enough for uptake and usage. However, it does not specify how concepts may relate to one another.</p>
<p>RDF is part of the <a href="http://www.w3.org/Consortium/">W3C</a>&#8216;s <a href="http://www.w3.org/2001/sw/">Semantic Web Activity</a>. It is a <a href="http://www.w3.org/Consortium/">W3C</a> Recommendation.</p>
<p>The <a href="http://ontotext.com/factforge/rdfs.html"><strong>Resource Description Framework Schema (RDFS)</strong></a> is an extension of RDF. It allows to define simple ontologies &#8211; models about concepts and their properties. They can be used to conclude new knowledge.</p>
<p>The <a href="http://ontotext.com/factforge/owl.html"><strong>Web Ontology Language (OWL)</strong></a> extends RDFS. It makes richer models of knowledge about things possible, but at the cost of those models being more complex for a computer to process.</p>
<p><strong>Original Location:</strong> <a href="http://ontotext.com/factforge/rdf.html" target="_blank">http://ontotext.com/factforge/rdf.html</a></p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>2010/08/15 -- <a href="http://blog.baturu.com/index.php/2010/08/15/customize_java_packages_generated_by_xmlbeans.html" title="定制 xmlbeans 所生成的 package">定制 xmlbeans 所生成的 package</a></li><li>2010/06/09 -- <a href="http://blog.baturu.com/index.php/2010/06/09/terminologies_in_rdf.html" title="RDF 中的术语">RDF 中的术语</a></li><li>2009/10/21 -- <a href="http://blog.baturu.com/index.php/2009/10/21/tutorial_of_soap_with_attachments_api_for_java.html" title="Tutorial of SOAP with Attachments API for Java">Tutorial of SOAP with Attachments API for Java</a></li><li>2009/07/23 -- <a href="http://blog.baturu.com/index.php/2009/07/23/whats_the_purpose_of_schemalocation_attribute_in_xml.html" title="XML 中的 schemaLocation 属性究竟是什么意思？">XML 中的 schemaLocation 属性究竟是什么意思？</a></li><li>2009/07/19 -- <a href="http://blog.baturu.com/index.php/2009/07/19/smtp_transport_binding_for_soap.html" title="SMTP Transport Binding for SOAP">SMTP Transport Binding for SOAP</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.baturu.com/index.php/2010/08/04/a_brief_introduction_of_whats_rdf.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial of SOAP with Attachments API for Java</title>
		<link>http://blog.baturu.com/index.php/2009/10/21/tutorial_of_soap_with_attachments_api_for_java.html</link>
		<comments>http://blog.baturu.com/index.php/2009/10/21/tutorial_of_soap_with_attachments_api_for_java.html#comments</comments>
		<pubDate>Wed, 21 Oct 2009 07:42:01 +0000</pubDate>
		<dc:creator>javafuns</dc:creator>
				<category><![CDATA[SOA]]></category>
		<category><![CDATA[SAAJ]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[Webservice]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://blog.baturu.com/?p=1067</guid>
		<description><![CDATA[随着web 服务、SOA 概念的兴起，和诸多 SOA 应用的实践，Java 阵营也审时度势，趁势推出相应的 API 以应对这一变化。SOAP 是 Java web 服务栈中很基础的一项技术，web 服务间以 SOAP 消息来互相通信。
SOAP with Attachments API for Java(简称 SAAJ) 就是 Java 阵营为访问 web 服务所提供的基础设施，它简化了对 SOAP 的处理。
SAAJ 包含 2 部分 APIs，其一用于创建消息，添加消息内容，其二则用于建立连接，发送 SOAP 消息。]]></description>
			<content:encoded><![CDATA[<p>随着web 服务、SOA 概念的兴起，和诸多 SOA 应用的实践，Java 阵营也审时度势，趁势推出相应的 API 以应对这一变化。SOAP 是 Java web 服务栈中很基础的一项技术，web 服务间以 SOAP 消息来互相通信。<br />
SOAP with Attachments API for Java(简称 SAAJ) 就是 Java 阵营为访问 web 服务所提供的基础设施，它简化了对 SOAP 的处理。<br />
SAAJ 包含 2 部分 APIs，其一用于创建消息，添加消息内容，其二则用于建立连接，发送 SOAP 消息。</p>
<p><strong>一. 创建 SOAP 消息</strong></p>
<p>SOAP 消息的 XML 文档结构在前一篇文章中已有图示。其中，SAAJ APIs 中的 SOAPMessage 类表示一个 SOAP 消息，SOAPPart 类表示 SOAP part，SOAPEnvelope 接口表示 SOAP envelope，等等。很多 SAAJ APIs 的接口都继承了 DOM 接口。<br />
当创建一个 SOAPMessage 时，该 SOAPMessage 会自动创建并包含 SOAP 消息所必须的部分：一个新的 SOAPMessage 对象会包含一个 SOAPPart 对象，这个 SOAPPart 则包含有一个 SOAPEnvelope 对象，该 SOAPEnvelope 对象会包含一个空的SOAPHeader 对象，紧接着是一个空的 SOAPBody 对象。SOAPHeader 在 SOAP 消息中是可选的，这里之所以自动创建它，是因为我们在 SOAP 消息中经常会使用到它。<br />
<span id="more-1067"></span></p>
<pre name="code" class="java">MessageFactory factory = MessageFactory.newInstance();
SOAPMessage message = factory.createMessage();</pre>
<p>默认是创建 SOAP 1.1 的消息，如果想要创建 SOAP 1.2 消息，那么代码如下：</p>
<pre name="code" class="java">MessageFactory factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);</pre>
<p>如果既想创建 SOAP 1.1 消息，又想创建 SOAP 1.2 消息，那么代码如下：</p>
<pre name="code" class="java">MessageFactory factory = MessageFactory.newInstance(SOAPConstants.DYNAMIC_SOAP_PROTOCOL
);</pre>
<p>接着，向消息中添加内容。</p>
<p>首先取得 SOAPMessage 中的 SOAPPart 对象：</p>
<pre name="code" class="java">SOAPPart soapPart = message.getSOAPPart();</pre>
<p>然后，我们从 SOAPPart 中取出 SOAPEnvelope 对象：</p>
<pre name="code" class="java">SOAPEnvelope envelope = soapPart.getEnvelope();</pre>
<p>有了 SOAPEnvelope 对象，就可以得到它的 SOAPHeader 和 SOAPBody 了。</p>
<pre name="code" class="java">SOAPHeader header = envelope.getHeader();
SOAPBody body = envelope.getBody();</pre>
<p>不过，你可能觉得做了这么多的工作才取得 SOAPHeader 和 SOAPBody 是不是太麻烦了？ SAAJ APIs 提供了便捷通道，直接通过 SOAPMessage 就可以获得 SOAPHeader 和 SOAPBody 对象：</p>
<pre name="code" class="java">SOAPHeader header = message.getSOAPHeader();
SOAPBody body = message.getSOAPBody();</pre>
<p>由于 SOAPHeader 是可选的，如果你不需要它，便可以去掉它，可以使用 DOM 接口的方法来删除：</p>
<pre name="code" class="java">header.detachNode();</pre>
<p>下面向 SOAPBody 对象中添加内容：</p>
<pre name="code" class="java">SOAPBody body = message.getSOAPBody();
QName bodyName = new QName("http://wombat.ztrade.com", "GetLastTradePrice", "m");
SOAPBodyElement bodyElement = body.addBodyElement(bodyName);
QName name = new QName("symbol");
SOAPElement symbol = bodyElement.addChildElement(name);
symbol.addTextNode("SUNW");</pre>
<p>这时的 SOAPBody 内容如下所示：<br />
<code><br />
&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt;<br />
&lt;SOAP-ENV:Body&gt;<br />
&lt;m:GetLastTradePrice xmlns:m="http://wombat.ztrade.com"&gt;<br />
&lt;symbol&gt;SUNW&lt;/symbol&gt;<br />
&lt;/m:GetLastTradePrice&gt;<br />
&lt;/SOAP-ENV:Body&gt;<br />
&lt;/SOAP-ENV:Envelope&gt;</code></p>
<p>如果你有一个以文件形式存在的 SOAP 消息，那么如下方式会使用创建一个 SOAPMessage 更便捷：</p>
<pre name="code" class="java">
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder builder = dbFactory.newDocumentBuilder();
Document document = builder.parse("file:///music/order/soap.xml");
DOMSource domSource = new DOMSource(document);

SOAPPart soapPart = message.getSOAPPart();
soapPart.setContent(domSource);
</pre>
<p>当然，如果已有一个 DOM document，想将它通过 SOAP 发送出去，SAAJ APIs 也提供了便捷方式：</p>
<pre name="code" class="java">
SOAPBody body = message.getSOAPBody();
SOAPBodyElement docElement = body.addDocument(document);
</pre>
<p>一个 SOAPMessage 可以包含一个或多个 attachment part，在 SAAJ APIs 中，使用 AttachmentPart 类表示 attachment part。由于 AttachmentPart 在 SOAPMessage 中是可选的，因此必须自己亲自动手去创建和添加它。如果一个 SOAPMessage 对象有一个或多个 attachments, 则每个 AttachmentPart 对象必须有一个 MIME header 用于指示它所包含的数据的类型。</p>
<p><strong>二. 创建连接并发送 SOAP 消息</strong></p>
<p>当消息已经创建好后，可以使用各种机制发送(例如JMS 或 JAXM)。在 SAAJ APIs 中，也提供了简单的发送机制。它使用 SOAPConnection 代表连接，SOAPConnection 对象是一中 point-to-point 连接，意味着它是直接从发送方到目标。<br />
首先创建连接 SOAPConnection 对象：</p>
<pre name="code" class="java">
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = soapConnectionFactory.createConnection();
</pre>
<p>发送消息：</p>
<pre name="code" class="java">
java.net.URL endpoint = new URL("http://wombat.ztrade.com/quotes");
SOAPMessage response = connection.call(message, endpoint);
</pre>
<p>一个连接使用了相当多的资源，所以使用结束后应尽早关闭：</p>
<pre name="code" class="java">
connection.close();
</pre>
<p>处理响应内容：</p>
<pre name="code" class="java">
SOAPBody soapBody = response.getSOAPBody();
java.util.Iterator iterator = soapBody.getChildElements(bodyName);
SOAPBodyElement bodyElement = (SOAPBodyElement)iterator.next();
String lastPrice = bodyElement.getValue();
System.out.print("The last price for SUNW is ");
System.out.println(lastPrice);
</pre>
<p><strong>三. 带附件的 SOAP 消息</strong></p>
<p>SAAJ APIs 中有 3 种方式创建附件。<br />
第一种：创建一个没有内容的附件</p>
<pre name="code" class="java">
AttachmentPart attachment = message.createAttachmentPart();
String stringContent = "Update address for Sunny Skies " + "Inc., to 10 Upbeat Street, Pleasant Grove, CA 95439";
attachment.setContent(stringContent, "text/plain");
attachment.setContentId("update_address");
message.addAttachmentPart(attachment);
</pre>
<p>setContent 方法的第一个参数 Object 是附件内容，第二个参数 String 则是 MIME 内容类型。MIME 内容类型会写入到 AttachmentPart 的 Header，且这个 MIME content type 是唯一强制要有的。SAAJ 提供了 Content-Type, Content-Id, and Content-Location headers 的 getter 和 setter 方法。</p>
<p>另外 2 个 SOAPMessage.createAttachment 方法会创建带内容的附件。其中一个方法，其参数类似于 AttachmentPart.setContent，它的 Object 可以是一个 String, 一个 stream, 一个 javax.xml.transform.Source object, 或者一个 javax.activation.DataHandler object。<br />
另外一个方法则需要参数 DataHandler object，来自于 JavaBeans Activation Framework (JAF) APIs. 使用一个 DataHandler object 是相当直观的。首先，为想要添加到附件中的文件创建一个 java.net.URL object。然后创建一个 DataHandler object：</p>
<pre name="code" class="java">
URL url = new URL("http://greatproducts.com/gizmos/img.jpg");
DataHandler dataHandler = new DataHandler(url);
AttachmentPart attachment = message.createAttachmentPart(dataHandler);
attachment.setContentId("attached_image");
message.addAttachmentPart(attachment);
</pre>
<p>这里之所以没有设置 MIME content type header，是因为 DataHandler 会含有这方面的信息。</p>
<p>访问附件内容：</p>
<pre name="code" class="java">
java.util.Iterator iterator = message.getAttachments();
while (iterator.hasNext()) {
AttachmentPart attachment = (AttachmentPart)iterator.next();
String id = attachment.getContentId();
String type = attachment.getContentType();
System.out.print("Attachment " + id + " has content type " + type);
if (type.equals("text/plain")) {
Object content = attachment.getContent();
System.out.println("Attachment contains:\n" + content);
}
}
</pre>
<p><strong>四. 创建 SOAPFault</strong><br />
for SOAP 1.1</p>
<pre name="code" class="java">
SOAPBody body = message.getSOAPBody();
SOAPFault fault = body.addFault();
QName faultName =
new QName(SOAPConstants.URI_NS_SOAP_ENVELOPE, "Server");
fault.setFaultCode(faultName);
fault.setFaultActor("http://gizmos.com/orders");
fault.setFaultString("Server not responding");
</pre>
<p>还可以向 SOAPFault 对象添加详细信息：</p>
<pre name="code" class="java">
Detail detail = fault.addDetail();
QName entryName = new QName("http://gizmos.com/orders/", "order", "PO");
DetailEntry entry = detail.addDetailEntry(entryName);
entry.addTextNode("Quantity element does not have a value");
QName entryName2 = new QName("http://gizmos.com/orders/", "order", "PO");
DetailEntry entry2 = detail.addDetailEntry(entryName2);
entry2.addTextNode("Incomplete address: no zip code");
</pre>
<p>注意：一个 SOAPFault 对象只能有一个 Detail 对象。</p>
<p>获取 SOAPFault 信息：</p>
<pre name="code" class="java">
SOAPBody body = newMessage.getSOAPBody();
if ( body.hasFault() ) {
SOAPFault newFault = body.getFault();
QName code = newFault.getFaultCodeAsQName();
String string = newFault.getFaultString();
String actor = newFault.getFaultActor();
System.out.println("SOAP fault contains: ");
System.out.println(" Fault code = " + code.toString());
System.out.println(" Local name = " + code.getLocalPart());
System.out.println(" Namespace prefix = " + code.getPrefix() + ", bound to " + code.getNamespaceURI());
System.out.println(" Fault string = " + string);
if ( actor != null ) {
System.out.println(" Fault actor = " + actor);
}
</pre>
<p>访问详细信息：</p>
<pre name="code" class="java">
Detail newDetail = newFault.getDetail();
if (newDetail != null) {
Iterator entries = newDetail.getDetailEntries();
while ( entries.hasNext() ) {
DetailEntry newEntry = (DetailEntry)entries.next();
String value = newEntry.getValue();
System.out.println(" Detail entry = " + value);
}
}
</pre>
<p><strong>五. 参考资料</strong></p>
<ol>
<li>The Java™ Web Services Tutorial (For Java Web Services Developer’s Pack, v2.0)</li>
</ol>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>2009/07/19 -- <a href="http://blog.baturu.com/index.php/2009/07/19/smtp_transport_binding_for_soap.html" title="SMTP Transport Binding for SOAP">SMTP Transport Binding for SOAP</a></li><li>2009/07/07 -- <a href="http://blog.baturu.com/index.php/2009/07/07/which-style-of-wsdl-should-i-use-reship.html" title="Which style of WSDL should I use? (reship)">Which style of WSDL should I use? (reship)</a></li><li>2009/10/15 -- <a href="http://blog.baturu.com/index.php/2009/10/15/structures_of_soap_with_attachments.html" title="Structures of SOAP with Attachments">Structures of SOAP with Attachments</a></li><li>2008/07/29 -- <a href="http://blog.baturu.com/index.php/2008/07/29/whats-new-in-wsdl-20.html" title="What&#8217;s New in WSDL 2.0">What&#8217;s New in WSDL 2.0</a></li><li>2008/07/19 -- <a href="http://blog.baturu.com/index.php/2008/07/19/uddi-v302-uddi-programmers-apis-custody-and-ownership-transfer-api-set.html" title="UDDI 规范 v3.0.2 &#8211; UDDI Programmers APIs 之 Custody and Ownership Transfer API Set">UDDI 规范 v3.0.2 &#8211; UDDI Programmers APIs 之 Custody and Ownership Transfer API Set</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.baturu.com/index.php/2009/10/21/tutorial_of_soap_with_attachments_api_for_java.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML 中的 schemaLocation 属性究竟是什么意思？</title>
		<link>http://blog.baturu.com/index.php/2009/07/23/whats_the_purpose_of_schemalocation_attribute_in_xml.html</link>
		<comments>http://blog.baturu.com/index.php/2009/07/23/whats_the_purpose_of_schemalocation_attribute_in_xml.html#comments</comments>
		<pubDate>Thu, 23 Jul 2009 05:43:34 +0000</pubDate>
		<dc:creator>javafuns</dc:creator>
				<category><![CDATA[SOA]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://blog.baturu.com/?p=1001</guid>
		<description><![CDATA[在 XML 实例文档中有时会发现有 schemaLocation 属性。很多人对此非常疑惑，搞不清这个属性究竟是什么意思，究竟该如何使用。 schemaLocation 属性用来引用(schema)模式文档，解析器可以在需要的情况下使用这个文档对 XML 实例文档进行校验。它的值(URI)是成对出现的，第一个值表示命名空间，第二个值则表示描述该命名空间的模式文档的具体位置，两个值之间以空格分隔。当然，在必要情况下，可以为 schemaLocation 属性指派多个这样的值对。 &#60;p:Person xmlns:p="http://contoso.com/People" xmlns:v="http://contoso.com /Vehicles" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://contoso.com/People http://contoso.com/schemas/people.xsd http://contoso.com/schemas/Vehicles http://contoso.com/schemas/vehicles.xsd http://contoso.com/schemas/People http://contoso.com/schemas/people.xsd"&#62; &#60;name&#62;John&#60;/name&#62; &#60;age&#62;28&#60;/age&#62; &#60;height&#62;59&#60;/height&#62; &#60;v:Vehicle&#62; &#60;color&#62;Red&#60;/color&#62; &#60;wheels&#62;4&#60;/wheels&#62; &#60;seats&#62;2&#60;/seats&#62; &#60;/v:Vehicle&#62; &#60;/p:Person&#62; 如果为没有目标命名空间的模式文档指定位置，需用 noNamespaceSchemaLocation 属性. Related Posts:2010/08/15 -- 定制 xmlbeans 所生成的 package2009/07/07 -- Which style of WSDL should I use? (reship)2009/03/01 -- Java 程序中如何对 XML [...]]]></description>
			<content:encoded><![CDATA[<p>在 XML 实例文档中有时会发现有 schemaLocation 属性。很多人对此非常疑惑，搞不清这个属性究竟是什么意思，究竟该如何使用。</p>
<p>schemaLocation 属性用来引用(schema)模式文档，解析器可以在需要的情况下使用这个文档对 XML 实例文档进行校验。它的值(URI)是成对出现的，第一个值表示命名空间，第二个值则表示描述该命名空间的模式文档的具体位置，两个值之间以空格分隔。当然，在必要情况下，可以为 schemaLocation 属性指派多个这样的值对。</p>
<pre name="code" class="xml">&lt;p:Person
  xmlns:p="http://contoso.com/People"
  xmlns:v="http://contoso.com /Vehicles"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation=
    "http://contoso.com/People

http://contoso.com/schemas/people.xsd

http://contoso.com/schemas/Vehicles

http://contoso.com/schemas/vehicles.xsd

http://contoso.com/schemas/People

    http://contoso.com/schemas/people.xsd"&gt;
  &lt;name&gt;John&lt;/name&gt;
  &lt;age&gt;28&lt;/age&gt;
  &lt;height&gt;59&lt;/height&gt;
  &lt;v:Vehicle&gt;
    &lt;color&gt;Red&lt;/color&gt;
    &lt;wheels&gt;4&lt;/wheels&gt;
    &lt;seats&gt;2&lt;/seats&gt;
  &lt;/v:Vehicle&gt;
&lt;/p:Person&gt;</pre>
<p>如果为没有目标命名空间的模式文档指定位置，需用 noNamespaceSchemaLocation 属性.</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 94px; width: 1px; height: 1px;">
<pre class="xml"></pre>
</div>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>2010/08/15 -- <a href="http://blog.baturu.com/index.php/2010/08/15/customize_java_packages_generated_by_xmlbeans.html" title="定制 xmlbeans 所生成的 package">定制 xmlbeans 所生成的 package</a></li><li>2009/07/07 -- <a href="http://blog.baturu.com/index.php/2009/07/07/which-style-of-wsdl-should-i-use-reship.html" title="Which style of WSDL should I use? (reship)">Which style of WSDL should I use? (reship)</a></li><li>2009/03/01 -- <a href="http://blog.baturu.com/index.php/2009/03/01/how-to-validate-xml-in-java-applications.html" title="Java 程序中如何对 XML 文档进行验证？">Java 程序中如何对 XML 文档进行验证？</a></li><li>2008/07/29 -- <a href="http://blog.baturu.com/index.php/2008/07/29/whats-new-in-wsdl-20.html" title="What&#8217;s New in WSDL 2.0">What&#8217;s New in WSDL 2.0</a></li><li>2010/08/04 -- <a href="http://blog.baturu.com/index.php/2010/08/04/a_brief_introduction_of_whats_rdf.html" title="A brief introduction of what is RDF">A brief introduction of what is RDF</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.baturu.com/index.php/2009/07/23/whats_the_purpose_of_schemalocation_attribute_in_xml.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SMTP Transport Binding for SOAP</title>
		<link>http://blog.baturu.com/index.php/2009/07/19/smtp_transport_binding_for_soap.html</link>
		<comments>http://blog.baturu.com/index.php/2009/07/19/smtp_transport_binding_for_soap.html#comments</comments>
		<pubDate>Sun, 19 Jul 2009 15:37:40 +0000</pubDate>
		<dc:creator>javafuns</dc:creator>
				<category><![CDATA[SOA]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[UDDI]]></category>
		<category><![CDATA[Webservice]]></category>
		<category><![CDATA[WSDL]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://blog.baturu.com/?p=984</guid>
		<description><![CDATA[SOAP 除了可以 bind 到 HTTP 上外, 也可以 bind 到 SMTP 上. 其实个人感觉, SOAP bind 到 SMTP 上的场景很少会使用到, 通常限于 one-way operation (比如通知等不需要响应). 如果需要实现 request/response, 那么是需要多做一些工作的(下文会有叙述). soap:binding element 的 transport 属性需指定一个 http://xxx(例如:http://schemas.xmlsoap.org/soap/smtp) URL 来表明所要 binding 的 protocol. 似乎这个 URL 是任意形式, 只要能让调用方知道要使用什么协议即可. 在 soap:address 要给定 mailto:xxxx@xxx.xxx 这样形式的 URI. &#60;service name="StockQuoteServiceBinding_service"&#62; &#60;port name="StockQuoteServiceBinding_port" binding="binding:StockQuoteServiceBinding"&#62; &#60;soap:address location="mailto:getQuote@test.com"/&#62; &#60;/port&#62; &#60;/service&#62; 注意: [...]]]></description>
			<content:encoded><![CDATA[<p>SOAP 除了可以 bind 到 HTTP 上外, 也可以 bind 到 SMTP 上. 其实个人感觉, SOAP bind 到 SMTP 上的场景很少会使用到, 通常限于 one-way operation (比如通知等不需要响应). 如果需要实现 request/response, 那么是需要多做一些工作的(下文会有叙述).</p>
<p>soap:binding element 的 transport 属性需指定一个 http://xxx(例如:http://schemas.xmlsoap.org/soap/smtp) URL 来表明所要 binding 的 protocol. 似乎这个 URL 是任意形式, 只要能让调用方知道要使用什么协议即可. 在 soap:address 要给定 mailto:xxxx@xxx.xxx 这样形式的 URI.</p>
<pre>    &lt;service name="StockQuoteServiceBinding_service"&gt;
        &lt;port name="StockQuoteServiceBinding_port"
                binding="binding:StockQuoteServiceBinding"&gt;
            &lt;soap:address location="mailto:getQuote@test.com"/&gt;
        &lt;/port&gt;
    &lt;/service&gt;</pre>
<p>注意: 在 soap:address element 中, 可能会有一些扩展元素, 例如smtp server, smtp username, smtp password, etc.</p>
<p>在需要 request / response 语义情况下, 需使用标准的 Message-Id 和 In-Reply-To SMTP header 来实现这一目标. 请求包含一个 Message-Id header, 相应的响应则在 In-Reply-To header 中使用请求的 Message-Id header 值, 同时也创建一个新的 Message-Id header. 这样, 在请求与响应之间便建立了关联.</p>
<p>请求:</p>
<pre>To: &lt;soap@example.org&gt;
 From: &lt;soap@client.com&gt;
 Reply-To: &lt;soap@client.com&gt;
 Date: Tue, 15 Nov 2001 23:27:00 -0700
 Message-Id: &lt;1F75D4D515C3EC3F34FEAB51237675B5@client.com&gt;
 MIME-Version: 1.0
 Content-Type: text/xml; charset=utf-8
 Content-Transfer-Encoding: QUOTED-PRINTABLE

 &lt;?xml version=3D"1.0" encoding=3D"UTF-8"?&gt;
 &lt;SOAP-ENV:Envelope SOAP-ENV:encodingStyle=3D"http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:SOAP-ENC=3D"http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:SOAP-ENV=3D"http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema"
 xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"&gt;
 &lt;SOAP-ENV:Body&gt;
 &lt;m:echoString xmlns:m=3D"http://soapinterop.org/"&gt;
 &lt;inputString&gt;get your SOAP over SMTP here !&lt;/inputString&gt;
 &lt;/m:echoString&gt;
 &lt;/SOAP-ENV:Body&gt;
 &lt;/SOAP-ENV:Envelope&gt;</pre>
<p>响应:</p>
<pre>To: &lt;soap@client.com&gt;
 From: &lt;soap@example.org&gt;
 Date: Tue, 13 Nov 2001 23:27:00 -0700
 In-Reply-To: &lt;1F75D4D515C3EC3F34FEAB51237675B5@client.com&gt;
 Message-Id: &lt;FF75D4D515C3EC3F34FEAB51237675B5@soap.example.org&gt;
 MIME-Version: 1.0
 Content-Type: TEXT/XML; charset=utf-8
 Content-Transfer-Encoding: QUOTED-PRINTABLE

 &lt;?xml version=3D"1.0" encoding=3D"UTF-8"?&gt;
 &lt;SOAP-ENV:Envelope SOAP-ENV:encodingStyle=3D"http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:SOAP-ENC=3D"http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:SOAP-ENV=3D"http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema"
 xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"&gt;
 &lt;SOAP-ENV:Body&gt;
 &lt;m:echoStringResponse xmlns:m=3D"http://soapinterop.org/"&gt;
 &lt;return&gt;get your SOAP over SMTP here !&lt;/return&gt;
 &lt;/m:echoStringResponse&gt;
 &lt;/SOAP-ENV:Body&gt;
 &lt;/SOAP-ENV:Envelope&gt;</pre>
<h4>Resources:</h4>
<ol>
<li> <a href="http://www.pocketsoap.com/specs/smtpbinding/" target="_blank">http://www.pocketsoap.com/specs/smtpbinding/</a></li>
<li><a href="http://people.apache.org/~pzf/SMTPBase64Binding.html" target="_blank">http://people.apache.org/~pzf/SMTPBase64Binding.html</a></li>
</ol>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>2009/07/07 -- <a href="http://blog.baturu.com/index.php/2009/07/07/which-style-of-wsdl-should-i-use-reship.html" title="Which style of WSDL should I use? (reship)">Which style of WSDL should I use? (reship)</a></li><li>2008/07/19 -- <a href="http://blog.baturu.com/index.php/2008/07/19/uddi-v302-uddi-programmers-apis-custody-and-ownership-transfer-api-set.html" title="UDDI 规范 v3.0.2 &#8211; UDDI Programmers APIs 之 Custody and Ownership Transfer API Set">UDDI 规范 v3.0.2 &#8211; UDDI Programmers APIs 之 Custody and Ownership Transfer API Set</a></li><li>2008/07/15 -- <a href="http://blog.baturu.com/index.php/2008/07/15/uddi-v302-uddi-programmers-apis-value-set-api-set.html" title="UDDI 规范 v3.0.2 &#8211; UDDI Programmers APIs 之 Value Set API Set">UDDI 规范 v3.0.2 &#8211; UDDI Programmers APIs 之 Value Set API Set</a></li><li>2008/07/13 -- <a href="http://blog.baturu.com/index.php/2008/07/13/uddi-v302-uddi-programmers-apis-security-policy-api-set.html" title="UDDI 规范 v3.0.2 &#8211; UDDI Programmers APIs 之 Security Policy API Set">UDDI 规范 v3.0.2 &#8211; UDDI Programmers APIs 之 Security Policy API Set</a></li><li>2008/07/07 -- <a href="http://blog.baturu.com/index.php/2008/07/07/uddi-v302-uddi-programmers-apis-publication-api-set-3.html" title="UDDI 规范 v3.0.2 &#8211; UDDI Programmers APIs 之 Publication API Set(3)">UDDI 规范 v3.0.2 &#8211; UDDI Programmers APIs 之 Publication API Set(3)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.baturu.com/index.php/2009/07/19/smtp_transport_binding_for_soap.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Which style of WSDL should I use? (reship)</title>
		<link>http://blog.baturu.com/index.php/2009/07/07/which-style-of-wsdl-should-i-use-reship.html</link>
		<comments>http://blog.baturu.com/index.php/2009/07/07/which-style-of-wsdl-should-i-use-reship.html#comments</comments>
		<pubDate>Tue, 07 Jul 2009 08:40:25 +0000</pubDate>
		<dc:creator>javafuns</dc:creator>
				<category><![CDATA[SOA]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[UDDI]]></category>
		<category><![CDATA[Webservice]]></category>
		<category><![CDATA[WSDL]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://blog.baturu.com/?p=973</guid>
		<description><![CDATA[A Web Services Description Language (WSDL) binding style can be RPC or document. The use can be encoded or literal. How do you determine which combination of style and use to use? The author describes the WSDL and SOAP messages for each combination to help you decide.]]></description>
			<content:encoded><![CDATA[<div class="ibm-column ibm-first">
<div class="author"><a class="dwauthor" rel="#authortip1" href="http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/?S_TACT=105AGX52&amp;S_CMP=content#author1">Russell Butek</a> (<a href="mailto:butek@us.ibm.com?subject=Which%20style%20of%20WSDL%20should%20I%20use?&amp;cc=flanders@us.ibm.com">butek@us.ibm.com</a>), SOA and Web services consultant, IBM</div>
<div id="authortip1" class="dwauthor-onload-state ibm-no-print" style="display: none;">
<div>
<div>
<div>
<div>Russell Butek is an SOA and Web services consultant for IBM. He has been one of the developers of IBM WebSphere Web services engine. He has also been a member the JAX-RPC Java Specification Request (JSR) expert group. He was involved in the implementation of Apache&#8217;s AXIS SOAP engine, driving AXIS 1.0 to comply with JAX-RPC 1.0.</div>
</div>
</div>
</div>
</div>
<p style="padding-left: 30px;"><strong>Date:</strong> 24 May  2005 (Published 31 Oct  2003)<br />
<strong>Level: </strong> Advanced</p>
<p><strong>Summary:</strong> A Web Services Description Language (WSDL) binding style can be RPC or document. The use can be encoded or literal. How do you determine which combination of style and use to use? The author describes the WSDL and SOAP messages for each combination to help you decide.</div>
<h2><a name="N10043"><span class="atitle">Introduction</span></a></h2>
<p>A WSDL document describes a Web service. A WSDL binding describes how the service is bound to a messaging protocol, particularly the SOAP messaging protocol. A WSDL SOAP binding can be either a Remote Procedure Call (RPC) style binding or a document style binding. A SOAP binding can also have an encoded use or a literal use. This gives you four style/use models:</p>
<ol>
<li>RPC/encoded</li>
<li>RPC/literal</li>
<li>Document/encoded</li>
<li>Document/literal</li>
</ol>
<p>Add to this collection a pattern which is commonly called the document/literal wrapped pattern and you have five binding styles to choose from when creating a WSDL file. Which one should you choose?</p>
<p>Before I go any further, let me clear up some confusion that many of us have stumbled over. The terminology here is very unfortunate: RPC versus document. These terms imply that the RPC style should be used for RPC programming models and that the document style should be used for document or messaging programming models. That is <em>not</em> the case at all. The style has nothing to do with a programming model. It merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model.</p>
<p>Likewise, the terms <em>encoded</em> and <em>literal</em> are only meaningful for the WSDL-to-SOAP mapping, though, at least here, the traditional meanings of the words make a bit more sense.</p>
<p>For this discussion, let&#8217;s start with the Java method in <a href="http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/?S_TACT=105AGX52&amp;S_CMP=content#listing1">Listing 1</a> and apply the JAX-RPC Java-to-WSDL rules to it (see <a href="http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/?S_TACT=105AGX52&amp;S_CMP=content#resources">Resources</a> for the JAX-RPC 1.1 specification).</p>
<p><a name="listing1"><strong>Listing 1. Java method</strong></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td class="code-outline">
<pre class="displaycode">public void myMethod(int x, float y);</pre>
</td>
</tr>
</tbody>
</table>
<div class="ibm-alternate-rule">
<hr /></div>
<h2><a name="N10082"><span class="atitle">RPC/encoded</span></a></h2>
<p>Take the method in <a href="http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/?S_TACT=105AGX52&amp;S_CMP=content#listing1">Listing 1</a> and run it through your favorite Java-to-WSDL tool, specifying that you want it to generate RPC/encoded WSDL. You should end up with something like the WSDL snippet in <a href="http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/?S_TACT=105AGX52&amp;S_CMP=content#listing2">Listing 2</a>.<br />
<a name="listing2"><strong>Listing 2. RPC/encoded WSDL for myMethod</strong></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td class="code-outline">
<pre class="displaycode">&lt;message name="myMethodRequest"&gt;
    &lt;part name="x" type="xsd:int"/&gt;
    &lt;part name="y" type="xsd:float"/&gt;
&lt;/message&gt;
&lt;message name="empty"/&gt;

&lt;portType name="PT"&gt;
    &lt;operation name="myMethod"&gt;
        &lt;input message="myMethodRequest"/&gt;
        &lt;output message="empty"/&gt;
    &lt;/operation&gt;
&lt;/portType&gt;

&lt;binding .../&gt;
&lt;!-- I won't bother with the details, just assume it's RPC/encoded. --&gt;</pre>
</td>
</tr>
</tbody>
</table>
<p>Now invoke this method with &#8220;5&#8243; as the value for parameter <code>x</code> and &#8220;5.0&#8243; for parameter <code>y</code>.  That sends a SOAP message which looks something like <a href="http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/?S_TACT=105AGX52&amp;S_CMP=content#listing3">Listing 3</a>.<br />
<a name="listing3"><strong>Listing 3. RPC/encoded SOAP message for myMethod</strong></a></p>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td class="code-outline">
<pre class="displaycode">&lt;soap:envelope&gt;
    &lt;soap:body&gt;
        &lt;myMethod&gt;
            &lt;x xsi:type="xsd:int"&gt;5&lt;/x&gt;
            &lt;y xsi:type="xsd:float"&gt;5.0&lt;/y&gt;
        &lt;/myMethod&gt;
    &lt;/soap:body&gt;
&lt;/soap:envelope&gt;</pre>
</td>
</tr>
</tbody>
</table>
<div class="ibm-container ibm-alt-header dw-container-sidebar">
<h3>A note about prefixes and namespaces</h3>
<div class="ibm-container-body">
<p>For the most part, for brevity, I ignore namespaces and prefixes in the listings in this article. I do use a few prefixes that you can assume are defined with the following namespaces:</p>
<ul>
<li>xmlns:xsd=&#8221;http://www.w3.org/2001/XMLSchema&#8221;</li>
<li>xmlns:xsi=&#8221;http://www.w3.org/2001/XMLSchema-instance&#8221;</li>
<li>xmlns:soap=&#8221;http://schemas.xmlsoap.org/soap/envelope/&#8221;</li>
</ul>
<p>For a discussion about namespaces and the WSDL-to-SOAP mapping, see paper &#8220;Handle namespaces in SOAP messages you create by hand&#8221; (see <a href="http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/?S_TACT=105AGX52&amp;S_CMP=content#resources">Resources</a>).</div>
</div>
<p>There are a number of things to notice about the WSDL and SOAP message for this RPC/encoded example:</p>
<h3><a name="N100D8"><span class="smalltitle">Strengths</span></a></h3>
<ul>
<li>The WSDL is about as straightforward as it&#8217;s possible for WSDL to be.</li>
<li>The operation name appears in the message, so the receiver has an easy time dispatching this message to the implementation of the operation.</li>
</ul>
<h3><a name="N100EA"><span class="smalltitle">Weaknesses</span></a></h3>
<ul>
<li>The type encoding info (such as <code>xsi:type="xsd:int"</code>) is usually just overhead which degrades throughput performance.</li>
<li>You cannot easily validate this message since only the <code>&lt;x ...&gt;5&lt;/x&gt;</code> and <code>&lt;y ...&gt;5.0&lt;/y&gt;</code> lines contain things defined in a schema; the rest of the <code>soap:body</code> contents comes from WSDL definitions.</li>
<li>Although it is legal WSDL, RPC/encoded is not WS-I compliant.</li>
</ul>
<p>Is there a way to keep the strengths and remove the weaknesses? Possibly. Let&#8217;s look at the RPC/literal style.</p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>2009/07/19 -- <a href="http://blog.baturu.com/index.php/2009/07/19/smtp_transport_binding_for_soap.html" title="SMTP Transport Binding for SOAP">SMTP Transport Binding for SOAP</a></li><li>2008/07/29 -- <a href="http://blog.baturu.com/index.php/2008/07/29/whats-new-in-wsdl-20.html" title="What&#8217;s New in WSDL 2.0">What&#8217;s New in WSDL 2.0</a></li><li>2008/07/19 -- <a href="http://blog.baturu.com/index.php/2008/07/19/uddi-v302-uddi-programmers-apis-custody-and-ownership-transfer-api-set.html" title="UDDI 规范 v3.0.2 &#8211; UDDI Programmers APIs 之 Custody and Ownership Transfer API Set">UDDI 规范 v3.0.2 &#8211; UDDI Programmers APIs 之 Custody and Ownership Transfer API Set</a></li><li>2008/07/15 -- <a href="http://blog.baturu.com/index.php/2008/07/15/uddi-v302-uddi-programmers-apis-value-set-api-set.html" title="UDDI 规范 v3.0.2 &#8211; UDDI Programmers APIs 之 Value Set API Set">UDDI 规范 v3.0.2 &#8211; UDDI Programmers APIs 之 Value Set API Set</a></li><li>2008/07/13 -- <a href="http://blog.baturu.com/index.php/2008/07/13/uddi-v302-uddi-programmers-apis-security-policy-api-set.html" title="UDDI 规范 v3.0.2 &#8211; UDDI Programmers APIs 之 Security Policy API Set">UDDI 规范 v3.0.2 &#8211; UDDI Programmers APIs 之 Security Policy API Set</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.baturu.com/index.php/2009/07/07/which-style-of-wsdl-should-i-use-reship.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>关于 XML standalone 的解释</title>
		<link>http://blog.baturu.com/index.php/2009/03/02/whats-usage-of-xml-standalone.html</link>
		<comments>http://blog.baturu.com/index.php/2009/03/02/whats-usage-of-xml-standalone.html#comments</comments>
		<pubDate>Mon, 02 Mar 2009 13:09:35 +0000</pubDate>
		<dc:creator>javafuns</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://blog.baturu.com/?p=686</guid>
		<description><![CDATA[XML standalone 定义了外部定义的 DTD 文件的存在性. standalone element 有效值是 yes 和 no. 如下是一个例子: &#60;?xml version="1.0" encoding="UTF-8" standalone="no"?&#62; &#60;!DOCTYPE s1 PUBLIC "http://www.ibm.com/example.dtd" "example.dtd"&#62; &#60;s1&#62;.........&#60;/s1&#62; 值 no 表示这个 XML 文档不是独立的而是依赖于外部所定义的一个 DTD.  值 yes 表示这个 XML 文档是自包含的(self-contained). Related Posts:2010/08/15 -- 定制 xmlbeans 所生成的 package2009/03/01 -- Java 程序中如何对 XML 文档进行验证？2010/08/04 -- A brief introduction of what is RDF2010/07/16 -- wait [...]]]></description>
			<content:encoded><![CDATA[<p>XML standalone 定义了外部定义的 DTD 文件的存在性. standalone element 有效值是 <code>yes</code> 和 <code>no</code>. 如下是一个例子:<br />
<code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;<br />
&lt;!DOCTYPE s1 PUBLIC "http://www.ibm.com/example.dtd" "example.dtd"&gt;<br />
&lt;s1&gt;.........&lt;/s1&gt;</code><br />
值 <code>no</code> 表示这个 XML 文档不是独立的而是依赖于外部所定义的一个 DTD.  值 <code>yes</code> 表示这个 XML 文档是自包含的(self-contained).</p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>2010/08/15 -- <a href="http://blog.baturu.com/index.php/2010/08/15/customize_java_packages_generated_by_xmlbeans.html" title="定制 xmlbeans 所生成的 package">定制 xmlbeans 所生成的 package</a></li><li>2009/03/01 -- <a href="http://blog.baturu.com/index.php/2009/03/01/how-to-validate-xml-in-java-applications.html" title="Java 程序中如何对 XML 文档进行验证？">Java 程序中如何对 XML 文档进行验证？</a></li><li>2010/08/04 -- <a href="http://blog.baturu.com/index.php/2010/08/04/a_brief_introduction_of_whats_rdf.html" title="A brief introduction of what is RDF">A brief introduction of what is RDF</a></li><li>2010/07/16 -- <a href="http://blog.baturu.com/index.php/2010/07/16/wait_and_notifyall_in_java_multithreading.html" title="wait and notifyAll in Java multi-threading">wait and notifyAll in Java multi-threading</a></li><li>2010/07/13 -- <a href="http://blog.baturu.com/index.php/2010/07/13/5_things_you_didnt_know_about_java_util_concurrent.html" title="关于 java.util.concurrent 您不知道的 5 件事(转载)">关于 java.util.concurrent 您不知道的 5 件事(转载)</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.baturu.com/index.php/2009/03/02/whats-usage-of-xml-standalone.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java 程序中如何对 XML 文档进行验证？</title>
		<link>http://blog.baturu.com/index.php/2009/03/01/how-to-validate-xml-in-java-applications.html</link>
		<comments>http://blog.baturu.com/index.php/2009/03/01/how-to-validate-xml-in-java-applications.html#comments</comments>
		<pubDate>Sun, 01 Mar 2009 13:39:41 +0000</pubDate>
		<dc:creator>javafuns</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://blog.baturu.com/?p=679</guid>
		<description><![CDATA[Table Of Content Introduction Validation when parsing Validation against preparsed schema Validate a DOMSource or SAXSource against preparsed schema Introduction XML 作为一种数据存储和描述语言，这些年得到了广泛运用，尤其以web服务为代表。XML之所以广受欢迎，原因之一是它具有丰富的数据描述手段，你甚至可以对要存储的数据做出各种限制: 字符串长度，数字大小，等等。 最早的XML使用DTD(Document Type Definition)进行定义，后来人们又发明了XML Schema。XML Schema本质上也是一种XML，这相比DTD大大减少了学习曲线，而且XML Schema提供了更丰富的校验机制。 参看《XML Schema 与 XML DTD 的技术比较与分析》，有更详细的比较。 Validation when parsing XML 的解析API 即 JAXP (Java API for XML Processing) 提供有两种方式：SAX(Simple API for XML) 和 DOM。SAX 基于事件方式，边解析边处理，适用于大文件；DOM 则将整个XML文件全部读入，以Tree形式存在于内存中，可以对这个Tree进行增删改等操作。 [...]]]></description>
			<content:encoded><![CDATA[<h4>Table Of Content</h4>
<p style="padding-left: 30px;">Introduction</p>
<p style="padding-left: 30px;">Validation when parsing</p>
<p style="padding-left: 30px;">Validation against preparsed schema</p>
<p style="padding-left: 30px;">Validate a DOMSource or SAXSource against preparsed schema</p>
<h4>Introduction</h4>
<p style="padding-left: 30px;">XML 作为一种数据存储和描述语言，这些年得到了广泛运用，尤其以web服务为代表。XML之所以广受欢迎，原因之一是它具有丰富的数据描述手段，你甚至可以对要存储的数据做出各种限制: 字符串长度，数字大小，等等。</p>
<p style="padding-left: 30px;">最早的XML使用DTD(Document Type Definition)进行定义，后来人们又发明了XML Schema。XML Schema本质上也是一种XML，这相比DTD大大减少了学习曲线，而且XML Schema提供了更丰富的校验机制。</p>
<p style="padding-left: 30px;">参看《<a title="XML Schema 与 DTD 的技术比较和分析" href="http://www.ibm.com/developerworks/cn/xml/x-sd/index.html" target="_blank">XML Schema 与 XML DTD 的技术比较与分析</a>》，有更详细的比较。</p>
<p><span id="more-679"></span></p>
<h4>Validation when parsing</h4>
<p style="padding-left: 30px;">XML 的解析API 即 JAXP (Java API for XML Processing) 提供有两种方式：SAX(Simple API for XML) 和 DOM。SAX 基于事件方式，边解析边处理，适用于大文件；DOM 则将整个XML文件全部读入，以Tree形式存在于内存中，可以对这个Tree进行增删改等操作。</p>
<ul>
<li>配置 DocumentBuilderFactory 或 SAXParserFactory</li>
</ul>
<p style="padding-left: 30px;">以下语句(以DOM方式为例，SAX同理)使得解析时对XML文档进行校验且命名空间敏感。</p>
<pre name="code" class="java">DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance()
factory.setNamespaceAware(true);
factory.setValidating(true);
try {
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
}
catch (IllegalArgumentException x) {
// Happens if the parser does not support JAXP 1.2
// TODO: code here
}</pre>
<ul>
<li>为XML指定XML Schema</li>
</ul>
<p style="padding-left: 30px;">有两种方式：</p>
<p style="padding-left: 60px;">1). 在XML文档中指定</p>
<pre name="code" class="xml">
&lt;documentRoot
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation='YourSchemaDefinition.xsd'
&gt;
</pre>
<p>当有多个XML Schema时：</p>
<pre name="code" class="xml">
&lt;documentRoot
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="employeeDatabase.xsd"
xsi:schemaLocation="http://www.irs.gov/ fullpath/w2TaxForm.xsd http://www.ourcompany.com/ relpath/hiringForm.xsd"
xmlns:tax="http://www.irs.gov/"
xmlns:hiring="http://www.ourcompany.com/"
&gt;
...
</pre>
<p style="padding-left: 60px;">2). 在Java程序中指定</p>
<pre name="code" class="java">...
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance()
...
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", new File("YourSchemaDefinition.xsd"));</pre>
<p>当有多个XML Schema时：</p>
<pre name="code" class="java">static final String employeeSchema = "employeeDatabase.xsd";
static final String taxSchema = "w2TaxForm.xsd";
static final String hiringSchema = "hiringForm.xsd";

static final String[] schemas = {employeeSchema, taxSchema, hiringSchema};

static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";

...
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance()
...
factory.setAttribute(JAXP_SCHEMA_SOURCE, schemas);</pre>
<p>除了File及String Array参数以外，factory.setAttribute()方法的参数还可以是：</p>
<p style="padding-left: 30px;">一个指向 schema 的 URI 字符串</p>
<p style="padding-left: 30px;">一个带有 schema 内容的 InputStream</p>
<p style="padding-left: 30px;">一个 SAX InputSource</p>
<p style="padding-left: 30px;">一个 File</p>
<p style="padding-left: 30px;">一个 Object 数组, 它们可以是这里所定义的任何类型(指前几个).</p>
<h4>Validation against preparsed schema</h4>
<p>javax.xml.validation 包提供了对解析 schema 并根据已解析 schema 验证 XML 文档实例的支持. 可以根据一个已解析的 schema 对一个 DOMSource 或者 SAXSource 进行校验. 必要时, 已经解析的 schema 可以缓存起来以实现优化.</p>
<pre name="code" class="java">//parse an XML in non-validating mode and create a DOMSource
DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
dbfactory.setNamespaceAware(true);
dbfactory.setXIncludeAware(true);

DocumentBuilder parser = dbfactory.newDocumentBuilder();
Document doc = parser.parse(new File("data.xml"));

DOMSource xmlsource = new DOMSource(doc);

//create a SchemaFactory for loading W3C XML Schemas
SchemaFactory wxsfactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

//set the errorhandler for handling errors in schema itself
wxsfactory.setErrorHandler(schemaErrorHandler);

//load a W3C XML Schema
Schema schema = wxsfactory.newSchema(new File("myschema.xsd"));

// create a validator from the loaded schema
Validator validator = schema.newValidator();

//set the errorhandler for handling validation errors
validator.setErrorHandler(validationErrorHandler);

//validate the XML instance
validator.validate(xmlsource);</pre>
<p>在《Validation when parsing》一节中，我们得到的 parser 每次运行时都要解析一次 schema，如果需要重复解析同一个 schema 的多个 XML 实例时，性能将极低。<br />
使用本节所介绍的 JAXP 1.3 的 validation APIs，我们只需要解析一次 schema 然后将其缓存起来多次使用，可极大提升效率。</p>
<pre name="code" class="java">
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setSchema(schema);
SAXParser saxParser = spf.newSAXParser();
saxParser.parse(new File("instance.xml"), myHandler);
</pre>
<p>需注意的是不必设置 parser 的 validation 为 true，也不需要设置 schemaLanguage 或 schemaSource 属性。而且，混合使用 schemaLanguage(或 schemaSource) 属性和 schema 实例将导致 SAXException 异常。</p>
<p>注意事项：<br />
a). SchemaFactory 不是线程安全的，所以多线程程序中尤其要注意<br />
b). Schema 是线程安全的，且是immutable的，所以可以将其实例缓存以提升性能，可以在多个 parsers 间甚至多个线程间共享使用.<br />
c). Validator 不是线程安全的</p>
<h4>Validate a DOMSource or SAXSource against preparsed schema</h4>
<p>有时我们有的并不是一个 File 而是一个 SAX 对象或者 DOM 对象(比如得到的已解析过的SOAP消息)，仍可以使用Validation APIs进行校验。</p>
<pre name="code" class="java">
Document document = //DOM object
validator.validate(new DOMSource(document), new DOMResult());
</pre>
<p>参考资料：<br />
1). <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JAXPDOM8.html" target="_blank">Validating with XML Schema</a><br />
2). <a href="http://java.sun.com/developer/technicalArticles/xml/jaxp1-3/" target="_blank">Easy and Efficient XML Processing: Upgrade to JAXP 1.3</a></p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>2010/08/15 -- <a href="http://blog.baturu.com/index.php/2010/08/15/customize_java_packages_generated_by_xmlbeans.html" title="定制 xmlbeans 所生成的 package">定制 xmlbeans 所生成的 package</a></li><li>2009/07/23 -- <a href="http://blog.baturu.com/index.php/2009/07/23/whats_the_purpose_of_schemalocation_attribute_in_xml.html" title="XML 中的 schemaLocation 属性究竟是什么意思？">XML 中的 schemaLocation 属性究竟是什么意思？</a></li><li>2009/07/07 -- <a href="http://blog.baturu.com/index.php/2009/07/07/which-style-of-wsdl-should-i-use-reship.html" title="Which style of WSDL should I use? (reship)">Which style of WSDL should I use? (reship)</a></li><li>2009/05/15 -- <a href="http://blog.baturu.com/index.php/2009/05/15/assign_default_schema_for_db2_in_hibernate.html" title="HIBERNATE－为DB2指定默认schema">HIBERNATE－为DB2指定默认schema</a></li><li>2009/03/02 -- <a href="http://blog.baturu.com/index.php/2009/03/02/whats-usage-of-xml-standalone.html" title="关于 XML standalone 的解释">关于 XML standalone 的解释</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.baturu.com/index.php/2009/03/01/how-to-validate-xml-in-java-applications.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML Schema 中 dateTime 类型的解释</title>
		<link>http://blog.baturu.com/index.php/2008/08/18/the-datetime-type-in-xml-schema.html</link>
		<comments>http://blog.baturu.com/index.php/2008/08/18/the-datetime-type-in-xml-schema.html#comments</comments>
		<pubDate>Mon, 18 Aug 2008 08:05:38 +0000</pubDate>
		<dc:creator>javafuns</dc:creator>
				<category><![CDATA[SOA]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://blog.baturu.com/?p=191</guid>
		<description><![CDATA[dateTime 类型的形式为：&#8217;-'? yyyy &#8216;-&#8217; mm &#8216;-&#8217; dd &#8216;T&#8217; hh &#8216;:&#8217; mm &#8216;:&#8217; ss (&#8216;.&#8217; s+)? (zzzzzz)?，其中： &#8216;-&#8217;? yyyy 是一个4位或者更多位数的可使用负号的数字，表示年份；如果多于4位数字，则打头数字不能是0， &#8217;0000&#8242; 也是禁止的；同样需要注意的是+号也不允许使用; 剩下的 &#8216;-&#8217; 是时间中各部分的分隔符; 第一个 mm 是一个2位数字，表示月份; dd 是一个2位数字，表示日期; &#8216;T&#8217; 是一个分隔符，指明后面是日期中的时间; hh 是一个2位数字，表示小时；如果分钟和秒是 0，那么使用 &#8217;24&#8242; 是允许的, 这个如此表示的 dateTime 值马上转为下一天的值(the dateTime value so represented is the first instant of the following day); &#8216;:&#8217; 是一个时间中各部分的分隔符; 第二个 mm [...]]]></description>
			<content:encoded><![CDATA[<p>dateTime 类型的形式为：&#8217;-'? yyyy &#8216;-&#8217; mm &#8216;-&#8217; dd &#8216;T&#8217; hh &#8216;:&#8217; mm &#8216;:&#8217; ss (&#8216;.&#8217; s+)? (zzzzzz)?，其中：</p>
<ul>
<li>&#8216;-&#8217;? yyyy 是一个4位或者更多位数的可使用负号的数字，表示年份；如果多于4位数字，则打头数字不能是0， &#8217;0000&#8242; 也是禁止的；同样需要注意的是+号也不允许使用;</li>
<li>剩下的 &#8216;-&#8217; 是时间中各部分的分隔符;</li>
<li>第一个 mm 是一个2位数字，表示月份;</li>
<li>dd 是一个2位数字，表示日期;</li>
<li>&#8216;T&#8217; 是一个分隔符，指明后面是日期中的时间;</li>
<li>hh 是一个2位数字，表示小时；如果分钟和秒是 0，那么使用 &#8217;24&#8242; 是允许的, 这个如此表示的 dateTime 值马上转为下一天的值(the dateTime value so represented is the first instant of the following day);</li>
<li>&#8216;:&#8217; 是一个时间中各部分的分隔符;</li>
<li>第二个 mm 是一个2位数的数字，表示分钟数;</li>
<li>ss 是一个2位整数数字，表示完整的秒数;</li>
<li>&#8216;.&#8217; s+ (如果有) 表示秒数的小数部分;</li>
<li>zzzzzz (如果有) 表示时区 (如下面所描述的).</li>
</ul>
<p>例如，2002-10-10T12:00:00-05:00 是 2002-10-10T17:00:00Z，比 2002-10-10T12:00:00Z 晚 5 个小时.</p>
<p>For further guidance on arithmetic with dateTimes and durations, see <a title="dateTime" href="http://www.w3.org/TR/xmlschema-2/#adding-durations-to-dateTimes" target="_blank">Adding durations to dateTimes (§E)</a>.</p>
<p><strong>关于 TimeZone：</strong></p>
<p>时区中的小时数上限是14，分钟数上限是59，除非小时数是 14，而分钟数必须是 0。</p>
<p>时区的形式是 ((&#8216;+&#8217; | &#8216;-&#8217;) hh &#8216;:&#8217; mm) | &#8216;Z&#8217;，其中：</p>
<ul>
<li>hh 是一个2位数字 (必要情况下打头数字是0)，表示小时数</li>
<li>mm 是一个2位数字，表示分钟数</li>
<li>&#8216;+&#8217; 指明是一个正的时间段</li>
<li>&#8216;-&#8217; 指明是一个负的时间段</li>
</ul>
<p>&#8216;+00:00&#8242;, &#8216;-00:00&#8242;, 和 &#8216;Z&#8217; 都表示相同的 0 时区，即UTC; &#8216;Z&#8217; 是它的规范表现方式.</p>
<p>当将一个时区加到一个 UTC dateTime 中，结果是该日期和时间“位于这个时区中”。例如，2002-10-10T12:00:00+05:00 是 2002-10-10T07:00:00Z，2002-10-10T00:00:00+05:00 是 2002-10-09T19:00:00Z.</p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>2010/08/15 -- <a href="http://blog.baturu.com/index.php/2010/08/15/customize_java_packages_generated_by_xmlbeans.html" title="定制 xmlbeans 所生成的 package">定制 xmlbeans 所生成的 package</a></li><li>2010/08/04 -- <a href="http://blog.baturu.com/index.php/2010/08/04/a_brief_introduction_of_whats_rdf.html" title="A brief introduction of what is RDF">A brief introduction of what is RDF</a></li><li>2009/10/21 -- <a href="http://blog.baturu.com/index.php/2009/10/21/tutorial_of_soap_with_attachments_api_for_java.html" title="Tutorial of SOAP with Attachments API for Java">Tutorial of SOAP with Attachments API for Java</a></li><li>2009/07/23 -- <a href="http://blog.baturu.com/index.php/2009/07/23/whats_the_purpose_of_schemalocation_attribute_in_xml.html" title="XML 中的 schemaLocation 属性究竟是什么意思？">XML 中的 schemaLocation 属性究竟是什么意思？</a></li><li>2009/07/19 -- <a href="http://blog.baturu.com/index.php/2009/07/19/smtp_transport_binding_for_soap.html" title="SMTP Transport Binding for SOAP">SMTP Transport Binding for SOAP</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.baturu.com/index.php/2008/08/18/the-datetime-type-in-xml-schema.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What&#8217;s New in WSDL 2.0</title>
		<link>http://blog.baturu.com/index.php/2008/07/29/whats-new-in-wsdl-20.html</link>
		<comments>http://blog.baturu.com/index.php/2008/07/29/whats-new-in-wsdl-20.html#comments</comments>
		<pubDate>Tue, 29 Jul 2008 14:28:03 +0000</pubDate>
		<dc:creator>javafuns</dc:creator>
				<category><![CDATA[SOA]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[WSDL]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://blog.baturu.com/?p=178</guid>
		<description><![CDATA[原文：http://www.xml.com/pub/a/ws/2004/05/19/wsdl2.html?page=1 by Arulazi Dhesiaseelan May 20, 2004 // W3C 的 Web Services Description Working Group, Web Services Activity 的一个子组织, 已经为描述 web service 定义了一种语言, 也定义了与他们交互的可能方式. The WG 于 26 March 2004 发布了 WSDL 2.0 工作草稿. 这是 WSDL 进化史上的一个重要里程碑. 本文中, 我讨论了相对于 WSDL 1.1 规范所作出的修改以及其它对 web 服务描述语言的主要改进. W3C WSDL 2.0 工作草稿 W3C 已经公布了下列核心工作草稿作为该工作组交付物一部分: Web Services Description Language (WSDL) [...]]]></description>
			<content:encoded><![CDATA[<p>原文：<a title="英文原文" href="http://www.xml.com/pub/a/ws/2004/05/19/wsdl2.html?page=1" target="_blank">http://www.xml.com/pub/a/ws/2004/05/19/wsdl2.html?page=1</a></p>
<p><span class="secondary">by <a href="http://www.xml.com/pub/au/233">Arulazi Dhesiaseelan</a></span><br />
<span class="secondary">May 20, 2004</span></p>
<p><!-- mega preparse mp: --><!-- XML MPU Ad --></p>
<div style="float: right; padding-left: 15px;"><script src="http://ocp.com.com/ad.js" type="text/javascript"></script> <script type="text/JavaScript">// <![CDATA[
      var CN_AD = new Object();
      CN_AD.AD_SZ = "300wx250h";
      CN_AD.PTYPE = "publisher";
      cnetGetAd(CN_AD);
// ]]&gt;</script><script src="http://mads.com.com/cnet-ad?CLIENT:ID=SJS&amp;celt=js&amp;x-cb=80775927&amp;AD_SZ=300wx250h&amp;PTYPE=publisher" type="text/javascript"></script><!-- no overgif in ad style --></div>
<p><!-- End ad --> <!-- me -->W3C 的 <a href="http://www.w3.org/2002/ws/desc/">Web Services Description Working Group</a>, <a href="http://www.w3.org/2002/ws/Activity">Web Services Activity</a> 的一个子组织, 已经为描述 web service 定义了一种语言, 也定义了与他们交互的可能方式. The WG 于  26 March 2004 发布了 WSDL 2.0 工作草稿. 这是 WSDL 进化史上的一个重要里程碑. 本文中, 我讨论了相对于 WSDL 1.1 规范所作出的修改以及其它对 web 服务描述语言的主要改进.</p>
<h3>W3C WSDL 2.0 工作草稿</h3>
<p>W3C 已经公布了下列核心工作草稿作为该工作组交付物一部分:</p>
<ul>
<li><a href="http://www.w3.org/TR/wsdl20/">Web Services Description Language (WSDL) Version 2.0 Part 1: Core Language</a><!-- sidebar begins --> <!-- don't move sidebars --> <!-- sidebar ends --></li>
<li><a href="http://www.w3.org/TR/wsdl20-patterns/">Web Services Description Language (WSDL) Version 2.0 Part 2: Message Patterns</a></li>
<li><a href="http://www.w3.org/TR/wsdl12-bindings/">Web Services Description Language (WSDL) Version 1.2 Part 3: Bindings</a></li>
</ul>
<p>其它相关工作草稿包括需求和使用场景.</p>
<ul>
<li><a href="http://www.w3.org/TR/ws-desc-reqs/">Web Services Description Requirements</a></li>
<li><a href="http://www.w3.org/TR/ws-desc-usecases/">Web Services Description Usage Scenarios</a></li>
</ul>
<p>W3C XML Schema definition for WSDL 2.0 specification 可见于 <a href="http://www.w3.org/2003/11/wsdl/">http://www.w3.org/2003/11/wsdl/</a>.</p>
<p>The <a href="http://www.w3.org/2002/ws/desc/">editor&#8217;s copies</a> of these documents provide updated information about the progress of these specifications.</p>
<h3>Changes from the WSDL 1.1 Specification</h3>
<p>WSDL 1.2 重命名为 WSDL 2.0 因为它相对 WSDL 1.1 有很大不同. 这其中的一些改变包括:</p>
<ul type="disc">
<li>进一步加强了 WSDL 的语义. 这是在 WSDL 2.0 中要求 targetNamespace 是 definitions element 的一个必需属性的原因之一.</li>
<li> 去掉了 message 结构.</li>
<li>不再支持操作重载.</li>
<li><code>PortTypes</code> 重命名为 <code>interfaces</code>. 支持 interface 使用 extends 属性实现继承.</li>
<li><code>Ports</code> 重命名为 <code>endpoints</code>.</li>
</ul>
<p><span id="more-178"></span></p>
<h3>WSDL 2.0 Conceptual Model</h3>
<p>一个 web service 的描述可以模型化为两部分. 在抽象部分里, WSDL 通过类型系统描述了 web service 发送和接收的消息, 典型的是使用 W3C XML Schema. Message exchange patterns define the sequence and cardinality of messages.<code> operation</code> 将 message exchange patterns 与一个或多个 messages 关联到一起. <code>interface</code> 在传输和报文中立基础上聚合这些 operations.</p>
<p>在描述的具体部分, <code>bindings</code> 指定了 interfaces 的传输方式和报文格式. service <code>endpoint</code> 将网络地址和 binding 关联在一起. 最后, <code>service</code> 将实现了共同的 interface 的 endpoints 聚合起来. Figure 1 展示了概念性的 WSDL 组件模型.</p>
<p align="center"><a href="http://blog.baturu.com/wp-content/uploads/2008/07/image002.jpg"><img class="aligncenter size-full wp-image-180" title="WSDL Conceptual model" src="http://blog.baturu.com/wp-content/uploads/2008/07/image002.jpg" alt="WSDL Conceptual model" width="400" height="301" /></a></p>
<p align="center">Figure 1: WSDL Conceptual model</p>
<h3>WSDL Components</h3>
<p>WSDL 提供了一组组件和它们的属性用于描述 web services. Listing 2 展示了使用 WSDL 2.0 描述的骨架. 下一章节给出每个组件的简要概览.</p>
<pre><code>&lt;definitions targetNamespace="xs:anyURI"&gt;
&lt;documentation /&gt; ?
[&lt;import /&gt; | &lt;include /&gt; ] *
&lt;types /&gt; ?
[&lt;interface /&gt; | &lt;binding /&gt; | &lt;service /&gt; ] *
&lt;/definitions&gt;</code></pre>
<p align="center">Listing 2: WSDL 2.0 Skeleton</p>
<h3>Definitions</h3>
<p><code>definitions</code> element 是 WSDL 文档的根. 它作为一个容器容纳关于 service 及其属性的所有必要信息. Figure 2 展示了 <code>definitions</code> element 的 schema. <code>definitions</code> element 的 <code>targetNamespace</code> 属性是必需的. namespace 能够直接或间接定义 WSDL 的语义. <code>definitions</code> element 也可以有其它可选属性指向其它各种 namespaces, 可用在 WSDL 文档中.</p>
<p class="secondary"><a href="http://blog.baturu.com/wp-content/uploads/2008/07/image004.jpg"><img class="aligncenter size-full wp-image-181" title="definitions schema" src="http://blog.baturu.com/wp-content/uploads/2008/07/image004.jpg" alt="definitions schema" width="500" height="352" /></a>Figure 2: <code>definitions</code> schema</p>
<h3>Include</h3>
<p><code>include</code> element 有助于模块化 web service 描述, 这样, 来自同一目标命名空间的各 service 定义组件可存放于不同的 WSDL 文档中, 这非常有利于在多个 web service 描述间使用和共享. <code>location</code> 属性是强制要有的, 用于指定 WSDL 文档的地址. 在被包含 WSDL 中的目标命名空间的实际值必须匹配主(including) WSDL 中 <code>definitions</code> element 的目标命名空间. Figure 3 展示了 <code>include</code> element 的 XML schema.</p>
<p class="secondary"><a href="http://blog.baturu.com/wp-content/uploads/2008/07/image006.jpg"><img class="aligncenter size-full wp-image-182" title="include schema" src="http://blog.baturu.com/wp-content/uploads/2008/07/image006.jpg" alt="include schema" width="400" height="149" /></a>Figure 3: <code>include</code> schema</p>
<p class="secondary">
<h3>Import</h3>
<p><code>import</code> element 非常类似于 <code>include</code> element, 除了被 imported WSDL 必须是在不同的 target namespaces. <code>import</code> element 的 <code>namespace</code> attribute 是强制性的, 但 <code>location</code> attribute 是可选的. Figure 4 展示了 <code>import</code> element 的 XML schema.</p>
<p class="secondary"><a href="http://blog.baturu.com/wp-content/uploads/2008/07/image008.jpg"><img class="aligncenter size-full wp-image-183" title="import schema" src="http://blog.baturu.com/wp-content/uploads/2008/07/image008.jpg" alt="import schema" width="400" height="151" /></a>Figure 4: <code>import</code> schema</p>
<h3>Types</h3>
<p><code>types</code> element 定义了交换消息使用的数据类型. WSDL 使用 W3C XML Schema 作为首选 schema 语言. 它也支持其它系统如 DTDs and RELAX NG. Schemas 可以在 WSDL 文档的 <code>types</code> element 中进行导入或者嵌入(importing or embedding). 导入是使用 <code>xs:import</code>, 嵌入是使用 <code>xs:schema</code>. 被导入或者嵌入的 schema components 可使用 QName 进行引用. Figure 5 展示了 <code>types</code> element 的 XML schema.</p>
<p class="secondary"><a href="http://blog.baturu.com/wp-content/uploads/2008/07/image010.jpg"><img class="aligncenter size-full wp-image-184" title="types schema" src="http://blog.baturu.com/wp-content/uploads/2008/07/image010.jpg" alt="types schema" width="400" height="181" /></a><br />
Figure 5: <code>types</code> schema</p>
<h3>Interface</h3>
<p><code>一个 </code><code>interface</code> element 封装了一组抽象操作和抽象消息. 它可以(也可以不)继承一个或多个其它 interfaces. Interfaces 在其它组件如 bindings 中使用 QName 进行引用. interface <code>operation</code> element 具有 name 和 pattern 属性, 都是必需的, 但 style 是可选属性. Figure 6 展示了 <code>interface</code> element 的 schema. Features 定义了在通信双方间进行消息交换相关的功能, 这可能包括可靠性, 安全, 相关性, 和路由. Property 用于控制 feature 的行为. It has a set of possible and permissible values specified by references to a schema description. These values can be shared among features.</p>
<p class="secondary"><a href="http://blog.baturu.com/wp-content/uploads/2008/07/image012.jpg"><img class="aligncenter size-full wp-image-185" title="interface schema" src="http://blog.baturu.com/wp-content/uploads/2008/07/image012.jpg" alt="interface schema" width="400" height="218" /></a>Figure 6: <code>interface</code> schema</p>
<h3>Binding</h3>
<p><code>binding</code> element 定义了底层传输方式和消息的报文格式. WSDL 中的每个 binding 都引用一个 interface. 所有在该 interface 中定义的 operations 必须在 binding 进行绑定. 在 service 中, endpoint 引用 binding. Both endpoints and bindings are modeled to support flexibility and location transparency. 多个具有不同网络地址的 endpoints 仍可以共享相同协议的 binding. WSDL 2.0 Bindings 规范定义了 binding 协议和消息格式的扩展, 例如 SOAP, HTTP and MIME.  Figure 7 展示了 <code>binding</code> element 的 XML schema.</p>
<p class="secondary"><a href="http://blog.baturu.com/wp-content/uploads/2008/07/image014.jpg"><img class="aligncenter size-full wp-image-186" title="binding schema" src="http://blog.baturu.com/wp-content/uploads/2008/07/image014.jpg" alt="binding schema" width="400" height="181" /></a>Figure 7: <code>binding</code> schema</p>
<h3>Service</h3>
<p>一个 <code>service</code> element 描述一组 endpoints, 每个 endpoint 都为一个 binding 引用一个单一网络地址. 所有其它协议特定信息都包含在 binding. Service 可以使用 QName 进行引用. <code>service</code> element 具有一个 <code>name</code> 和 <code>interface,</code> 都是必需的属性. Figure 8 展示了 <code>service</code> element 的 XML schema.</p>
<p class="secondary"><a href="http://blog.baturu.com/wp-content/uploads/2008/07/image016.jpg"><img class="aligncenter size-full wp-image-187" title="service schema" src="http://blog.baturu.com/wp-content/uploads/2008/07/image016.jpg" alt="service schema" width="400" height="160" /></a>Figure 8: <code>service schema</code></p>
<h3>WSDL Message Exchange Patterns</h3>
<p align="left">Message exchange patterns define the sequence and cardinality of messages within an operation. Several types of message patterns are defined in the â€œPart 2: Message Patternsâ€ of the WSDL 2.0 specifications. WSDL message exchange patterns uses fault generation rules to indicate the occurrence of faults. Message exchange may be terminated if fault generation happens regardless of standard rule sets. The following standard rule set outlines the behavior of fault generation.</p>
<ul>
<li>Fault Replaces Messages</li>
<li>Message Triggers Fault</li>
<li>No Faults</li>
</ul>
<p>Figure 9 shows the various message exchange patterns with their fault reference rules.</p>
<p class="secondary"><a href="http://blog.baturu.com/wp-content/uploads/2008/07/image018.jpg"><img class="aligncenter size-full wp-image-188" title="WSDL Message Exchange Patterns" src="http://blog.baturu.com/wp-content/uploads/2008/07/image018.jpg" alt="WSDL Message Exchange Patterns" width="400" height="317" /></a><br />
Figure 9: WSDL Message Exchange Patterns</p>
<p class="secondary">
<h3>Stock Quote Service Description in WSDL 1.1 &amp; WSDL 2.0</h3>
<p>在这一节, 你可以预览到一个用 WSDL 1.1 和 WSDL 2.0 描述的简单的股票报价服务(stock quote service). Listing 2 展示了用于描述股票报价服务的 XML schema types. Listing 3 and 4 分别展示了用 WSDL 1.1 和 WSDL 2.0 描述的股票报价服务接口定义. Listing 5 and 6 分别展示了 WSDL 1.1 和 WSDL 2.0 的股票报价服务实现的定义.</p>
<p><strong>http://example.com/stockquote/stockquoteV11.xsd</strong></p>
<pre><code>&lt;?xml version="1.0"?&gt;
&lt;schema targetNamespace="http://example.com/stockquote/schemas"
       <span lang="de-DE" xml:lang="de-DE">xmlns="http://www.w3.org/2000/10/XMLSchema"&gt;</span>
    &lt;element name="TradePriceRequest"&gt;
        &lt;complexType&gt;
            &lt;all&gt;
                &lt;element name="tickerSymbol" type="string"/&gt;
            &lt;/all&gt;
        &lt;/complexType&gt;
    &lt;/element&gt;
    &lt;element name="TradePrice"&gt;
        &lt;complexType&gt;
            &lt;all&gt;
                &lt;element name="price" type="float"/&gt;
            &lt;/all&gt;
        &lt;/complexType&gt;
    &lt;/element&gt;
&lt;/schema&gt;</code></pre>
<p style="border: medium none; padding: 0cm;"><strong> http://example.com/stockquote/stockquoteV20.xsd</strong></p>
<pre><code>&lt;?xml version="1.0"?&gt;
&lt;schema targetNamespace="http://example.com/stockquote/schemas"
       <span lang="de-DE" xml:lang="de-DE">xmlns="http://www.w3.org/2001/XMLSchema"&gt;</span>
    &lt;element name="TradePriceRequest"&gt;
        &lt;complexType&gt;
            &lt;all&gt;
&lt;element name="tickerSymbol" type="string"/&gt;
            &lt;/all&gt;
        &lt;/complexType&gt;
    &lt;/element&gt;
    &lt;element name="TradePrice"&gt;
        &lt;complexType&gt;
            &lt;all&gt;
&lt;element name="price" type="float"/&gt;
            &lt;/all&gt;
        &lt;/complexType&gt;
    &lt;/element&gt;
&lt;/schema&gt;</code></pre>
<p align="center">Listing 2: XML Schema definition for Stock Quote Service</p>
<p style="border: medium none; padding: 0cm;"><strong> http://example.com/stockquote/stockquoteV11.wsdl</strong></p>
<pre><code>&lt;?xml version="1.0"?&gt;
&lt;definitions name="StockQuote"
        targetNamespace="http://example.com/stockquote/definitions"
    <span lang="de-DE" xml:lang="de-DE">    xmlns:tns="http://example.com/stockquote/definitions"</span>
    <span lang="de-DE" xml:lang="de-DE">    xmlns:xsd1="http://example.com/stockquote/schemas"</span>
    <span lang="de-DE" xml:lang="de-DE">    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"</span>
        <span lang="de-DE" xml:lang="de-DE"> xmlns="http://schemas.xmlsoap.org/wsdl/"&gt;</span>
    &lt;import namespace="http://example.com/stockquote/schemas"
        location="http://example.com/stockquote/stockquoteV11.xsd"/&gt;
    &lt;message name="GetLastTradePriceInput"&gt;
        &lt;part name="body" element="xsd1:TradePriceRequest"/&gt;
    &lt;/message&gt;

    &lt;message name="GetLastTradePriceOutput"&gt;
        &lt;part name="body" element="xsd1:TradePrice"/&gt;
    &lt;/message&gt;

    &lt;portType name="StockQuotePortType"&gt;
        &lt;operation name="GetLastTradePrice"&gt;
            &lt;input message="tns:GetLastTradePriceInput"/&gt;
            &lt;output message="tns:GetLastTradePriceOutput"/&gt;
        &lt;/operation&gt;
    &lt;/portType&gt;
&lt;/definitions&gt;
</code></pre>
<p align="center">Listing 3: WSDL 1.1 Interface definition for Stock Quote Service</p>
<p style="border: medium none; padding: 0cm;"><strong> http://example.com/stockquote/stockquoteV20.wsdl</strong></p>
<pre><code>&lt;?xml version="1.0"?&gt;
&lt;definitions name="StockQuote"
        targetNamespace="http://example.com/stockquote/definitions"
        <span lang="de-DE" xml:lang="de-DE">xmlns:tns="http://example.com/stockquote/definitions"</span>
        <span lang="de-DE" xml:lang="de-DE">xmlns:xsd1="http://example.com/stockquote/schemas"</span>
        <span lang="de-DE" xml:lang="de-DE">xmlns:soap="http://www.w3.org/2003/11/wsdl/soap12"</span>
        <span lang="de-DE" xml:lang="de-DE">xmlns="http://www.w3.org/2003/11/wsdl"&gt;</span>

    &lt;import namespace="http://example.com/stockquote/schemas"
        location="http://example.com/stockquote/stockquoteV20.xsd"/&gt;
   <span lang="de-DE" xml:lang="de-DE">
    &lt;types&gt;</span>
        <span lang="de-DE" xml:lang="de-DE">&lt;schema targetNamespace="http://example.com/stockquote/definitions"&gt;</span>
            &lt;element name="GetLastTradePriceInput" type="xsd1:TradePriceRequest"/&gt;
            &lt;element name="GetLastTradePriceOutput" type="xsd1:TradePrice"/&gt;
        &lt;/schema&gt;
    &lt;/types&gt;

    &lt;interface name="StockQuoteInterface"&gt;
        &lt;operation name="GetLastTradePrice" pattern="http://www.w3.org/2003/11/wsdl/in-out"&gt;
            &lt;input message="tns:GetLastTradePriceInput"/&gt;
            &lt;output message="tns:GetLastTradePriceOutput"/&gt;
        &lt;/operation&gt;
    &lt;/interface&gt;
&lt;/definitions&gt;
</code></pre>
<p align="center">Listing 4: WSDL 2.0 Interface definition for Stock Quote Service</p>
<p style="border: medium none; padding: 0cm;"><strong> http://example.com/stockquote/stockquoteserviceV11.wsdl</strong></p>
<pre><code>&lt;?xml version="1.0"?&gt;
&lt;definitions name="StockQuote"
          targetNamespace="http://example.com/stockquote/service"
          <span lang="de-DE" xml:lang="de-DE">xmlns:tns="http://example.com/stockquote/service"</span>
          <span lang="de-DE" xml:lang="de-DE">xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"</span>
          <span lang="de-DE" xml:lang="de-DE">xmlns:defs="http://example.com/stockquote/definitions"</span>
          <span lang="de-DE" xml:lang="de-DE">xmlns="http://schemas.xmlsoap.org/wsdl/"&gt;</span>

    &lt;import namespace="http://example.com/stockquote/definitions"
            location="http://example.com/stockquote/stockquoteV11.wsdl"/&gt;
    &lt;binding name="StockQuoteSoapBinding" type="defs:StockQuotePortType"&gt;
        &lt;soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/&gt;
        &lt;operation name="GetLastTradePrice"&gt;
            &lt;soap:operation soapAction="http://example.com/GetLastTradePrice"/&gt;
            &lt;input&gt;
                &lt;soap:body use="literal"/&gt;
            &lt;/input&gt;
            &lt;output&gt;
                &lt;soap:body use="literal"/&gt;
            &lt;/output&gt;
        &lt;/operation&gt;
    &lt;/binding&gt;
    &lt;service name="StockQuoteService"&gt;
        &lt;documentation&gt;My first service&lt;/documentation&gt;
        &lt;port name="StockQuotePort" binding="tns:StockQuoteBinding"&gt;
            &lt;soap:address location="http://example.com/stockquote"/&gt;
        &lt;/port&gt;
    &lt;/service&gt;
&lt;/definitions&gt;
</code></pre>
<p align="center">Listing 5: WSDL 1.1 Implementation definition for Stock Quote Service</p>
<p style="border: medium none; padding: 0cm;"><strong> http://example.com/stockquote/stockquoteserviceV20.wsdl</strong></p>
<pre><code>&lt;?xml version="1.0"?&gt;
&lt;definitions name="StockQuote"
        targetNamespace="http://example.com/stockquote/service"
          <span lang="de-DE" xml:lang="de-DE">xmlns:tns="http://example.com/stockquote/service"</span>
          <span lang="de-DE" xml:lang="de-DE">xmlns:wsoap="http://www.w3.org/2003/11/wsdl/soap12"</span>
          <span lang="de-DE" xml:lang="de-DE">xmlns:defs="http://example.com/stockquote/definitions"</span>
          <span lang="de-DE" xml:lang="de-DE">xmlns="http://www.w3.org/2003/11/wsdl"&gt;</span>

    &lt;import namespace="http://example.com/stockquote/definitions"
        location="http://example.com/stockquote/stockquoteV12.wsdl"/&gt;

    &lt;binding name="StockQuoteSoapBinding" interface="defs:StockQuoteInterface"&gt;
        &lt;wsoap:binding protocol="http://www.w3.org/2003/11/wsdl/http"/&gt;
        &lt;operation name="GetLastTradePrice"&gt;
           &lt;wsoap:operation soapAction="http://example.com/GetLastTradePrice"/&gt;
           &lt;input&gt;
               &lt;wsoap:body/&gt;
           &lt;/input&gt;
           &lt;output&gt;
               &lt;wsoap:body/&gt;
           &lt;/output&gt;
        &lt;/operation&gt;
    &lt;/binding&gt;
    &lt;service name="StockQuoteService"&gt;
        &lt;documentation&gt;My stock quote service&lt;/documentation&gt;
        &lt;endpoint name="StockQuoteEndPoint" binding="tns:StockQuoteSoapBinding"&gt;
            &lt;wsoap:address location="http://example.com/stockquote"/&gt;
        &lt;/endpoint&gt;
    &lt;/service&gt;
&lt;/definitions&gt;
</code></pre>
<p align="center">Listing 6: WSDL 2.0 Implementation definition for Stock Quote Service</p>
<h3>Summary</h3>
<p>在本文中, 我解释了 WSDL 2.0 规范的工作草稿的一些详细情况. 该工作组正在讨论是否向现有规范中增加更多的特性以便提供高度灵活性和强壮的语言来描述 web services. 这些特性包括 web service 引用(references), 版本化(versioning), 属性(attributes), 和 compositors. 除了这些新特性, further refinements are made to the existing specification. 开发者社区希望在不久的将来能有一个更稳定的 WSDL 2.0 规范的版本.</p>
<p><!-- sidebar begins --></p>
<table border="0" cellspacing="8" cellpadding="4" width="80%" align="center">
<tbody>
<tr>
<td width="100%" valign="top" bgcolor="#efefef">
<div class="secondary">
<h3><strong>Resources</strong></h3>
<ul>
<li><a href="http://www.w3.org/2002/ws/desc/">W3C Web Services Description Working Group</a></li>
<li><a href="http://www.w3.org/2002/ws/desc/wsdl20-primer">W3C WSDL Version 2.0 Primer</a></li>
<li><a href="http://www.w3.org/TR/wsdl20/">W3C WSDL 2.0 Core Specifications</a></li>
<li><a href="http://www.w3.org/2003/11/wsdl/">XML Schema for WSDL 2.0</a></li>
<li><a href="http://webservices.xml.com/2004/05/19/examples/WSDL2.0-Schema-Documentation.zip">XML-SPY Generated WSDL 2.0 XML Schema Documentation</a></li>
</ul>
</div>
</td>
</tr>
</tbody>
</table>
<p><!-- sidebar ends --> <!-- end content --> <!-- ISI_LISTEN_STOP --> <!-- talk back --><a name="thread"></a></p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>2009/07/07 -- <a href="http://blog.baturu.com/index.php/2009/07/07/which-style-of-wsdl-should-i-use-reship.html" title="Which style of WSDL should I use? (reship)">Which style of WSDL should I use? (reship)</a></li><li>2009/07/19 -- <a href="http://blog.baturu.com/index.php/2009/07/19/smtp_transport_binding_for_soap.html" title="SMTP Transport Binding for SOAP">SMTP Transport Binding for SOAP</a></li><li>2010/08/15 -- <a href="http://blog.baturu.com/index.php/2010/08/15/customize_java_packages_generated_by_xmlbeans.html" title="定制 xmlbeans 所生成的 package">定制 xmlbeans 所生成的 package</a></li><li>2009/10/21 -- <a href="http://blog.baturu.com/index.php/2009/10/21/tutorial_of_soap_with_attachments_api_for_java.html" title="Tutorial of SOAP with Attachments API for Java">Tutorial of SOAP with Attachments API for Java</a></li><li>2009/07/23 -- <a href="http://blog.baturu.com/index.php/2009/07/23/whats_the_purpose_of_schemalocation_attribute_in_xml.html" title="XML 中的 schemaLocation 属性究竟是什么意思？">XML 中的 schemaLocation 属性究竟是什么意思？</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.baturu.com/index.php/2008/07/29/whats-new-in-wsdl-20.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
