XML Schema定义
XML Schema定义(XML Schema Definition,XSD)是一套W3C标准,用于基于XML的称为XML Schema的类型系统。用于定义的语言是一种称为XML模式定义语言(XML Schema Definition Language)的XML语法。Web 服务使用XML作为表示消息和数据的底层格式。因此,XSD成为Web服务类型系统的自然选择。
关于XSD的更多信息,请访问下面的网址:
XML Schema用于wscompile 配置文件
以下代码是用于创建wscompile配置文件的XML Schema:
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://java.sun.com/xml/ns/jax-rpc/ri/config"
targetNamespace="http://java.sun.com/xml/ns/jax-rpc/ri/config"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="1.0">
唯一允许的顶层元素是“configuration”。
所谓顶层元素,它必须包含3种可能的元素中的一种,相应地也会有3种不同的方式来为这种工具提供信息服务。
元素: (互斥的)
"service" —— 基于一组服务端接口的服务描述;
"modelfile" —— 预先保存好的模型文件 (wscompile中的-model选项)。
<xsd:element name="service" type="tns:serviceType"/>
<xsd:element name="wsdl" type="tns:wsdlType"/>
<xsd:element name="modelfile" type="tns:modelfileType"/>
属性:
"targetNamespace" ——用于生成WSDL 文档的目标命名空间;
"typeMappingRegistry"? ——用于该服务的类型映射注册表;
"handlerChains"? ——服务端的缺省处理程序链;
"namespaceMappingRegistry"? —— 到Java包映射信息的XML命名空间。
</xsd:documentation>
<xsd:element name=3D"interface" type=3D"tns:interfaceType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
<xsd:element name=3D"typeMappingRegistry" type=3D"tns:typeMappingRegistryType" minOccurs=3D"0"/>
<xsd:element name=3D"handlerChains" type=3D"tns:handlerChainsType" minOccurs=3D"0"/>
<xsd:element name=3D"namespaceMappingRegistry" type=3D"tns:namespaceMappingRegistryType" minOccurs=3D"0"/>
<xsd:attribute name=3D"name" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"targetNamespace" type=3D"xsd:anyURI" use=3D"required"/>
<xsd:attribute name=3D"typeNamespace" type=3D"xsd:anyURI" use=3D"required"/>
<xsd:attribute name=3D"packageName" type=3D"xsd:string" use=3D"required"/>
"servantName" (可选)—— 服务端实现类的名称;
"soapAction" (可选)—— 用于接口中所有操作的SOAPAction字符串;
"soapActionBase" (可选) —— 基于SOAPAction字符串的URI;给定操作的SOAPAction可以通过向这里提供的值中添加操作名称来获取;这个属性是“soapAction”专有的。
"handlerChains" ——指定该端点的处理程序链。
<xsd:element name=3D"handlerChains" type=3D"tns:handlerChainsType" minOccurs=3D"0"/>
</xsd:sequence>
<xsd:attribute name=3D"name" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"servantName" type=3D"xsd:string"/>
<xsd:attribute name=3D"soapAction" type=3D"xsd:string"/>
<xsd:attribute name=3D"soapActionBase" type=3D"xsd:string"/>
</xsd:complexType>
"typeMappingRegistry"? ——用于该服务的类型映射注册表;
"handlerChains"? —— 用于该服务端点的缺省处理程序链;
"namespaceMappingRegistry"? —— 到Java包的映射信息的XML命名空间。
</xsd:documentation>
<xsd:element name=3D"typeMappingRegistry" type=3D"tns:typeMappingRegistryType" minOccurs=3D"0"/>
<xsd:element name=3D"handlerChains" type=3D"tns:handlerChainsType" minOccurs=3D"0"/>
<xsd:element name=3D"namespaceMappingRegistry" type=3D"tns:namespaceMappingRegistryType" minOccurs=3D"0"/>
<xsd:attribute name=3D"location" type=3D"xsd:anyURI" use=3D"required"/>
<xsd:attribute name=3D"packageName" type=3D"xsd:string" use=3D"required"/>
</xsd:complexType>
属性:
"location" —— 模型文件的URL (通常以.xml.gz结尾);
<xsd:attribute name=3D"location" type=3D"xsd:anyURI" use=3D"required"/>
属性:
"runAt" ——指定该链是运行在客户端还是服务器上。
"roles" ——该链的SOAP角色。
元素:
"handler"* ——形成该链的处理程序序列。
<xsd:element name=3D"chain" type=3D"tns:chainType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
</xsd:sequence>
<xsd:list itemType=3D"xsd:anyURI"/>
属性:
"property"* ——该处理程序的初始化特性(property)。
<xsd:element name=3D"property" type=3D"tns:propertyType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
<xsd:attribute name=3D"className" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"headers" type=3D"tns:headerListType"/>
<xsd:simpleType name=3D"headerListType">
<xsd:documentation>
<xsd:list itemType=3D"xsd:QName"/>
<xsd:complexType name=3D"propertyType">
<xsd:documentation>
<xsd:sequence>
</xsd:sequence>
<xsd:attribute name=3D"name" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"value" type=3D"xsd:string" use=3D"required"/>
<xsd:simpleType name =3D"runAtType">
<xsd:documentation>
</xsd:documentation>
<xsd:restriction base=3D"xsd:string">
<xsd:enumeration value=3D"client"/>
<xsd:enumeration value=3D"server"/>
<xsd:complexType name=3D"typeMappingRegistryType">
<xsd:documentation>
元素:
"import"? —— XML Schema文档的列表,描述了用户定义的类型。
"typeMapping"* ——类型映射序列,每编码一个。
"additionalTypes"? ——即使不出现在服务接口上,也应该进行处理的附加Java类型的列表。
<xsd:sequence>
<xsd:element name=3D"import" type=3D"tns:importType" minOccurs=3D"0"/>
<xsd:element name=3D"typeMapping" type=3D"tns:typeMappingType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
<xsd:element name=3D"additionalTypes" type=3D"tns:additionalTypesType" minOccurs=3D"0"/>
</xsd:complexType>
<xsd:complexType name=3D"importType">
<xsd:documentation>
需要导入的模式文档的列表,通常描述被可插入式串行化器使用的模式类型。
<xsd:sequence>
<xsd:element name=3D"schema" type=3D"tns:schemaType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name=3D"schemaType">
<xsd:documentation>
属性:
"location" —— 指向模式文档的 URL。
</xsd:sequence>
<xsd:attribute name=3D"namespace" type=3D"xsd:anyURI" use=3D"required"/>
<xsd:attribute name=3D"location" type=3D"xsd:anyURI" use=3D"required"/>
<xsd:complexType name=3D"typeMappingType">
<xsd:documentation>
<xsd:element name=3D"entry" type=3D"tns:entryType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
<xsd:attribute name=3D"encodingStyle" type=3D"xsd:anyURI" use=3D"required"/>
</xsd:complexType>
<xsd:complexType name=3D"entryType">
<xsd:documentation>
属性:
"serializerFactory" —— 用于该类型的串行化器工厂类的名称;
"deserializerFactory" —— 用于该类型的反串行化器工厂类的名称。
</xsd:sequence>
<xsd:attribute name=3D"schemaType" type=3D"xsd:QName" use=3D"required"/>
<xsd:attribute name=3D"javaType" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"serializerFactory" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"deserializerFactory" type=3D"xsd:string" use=3D"required"/>
</xsd:complexType>
<xsd:complexType name=3D"additionalTypesType">
<xsd:documentation>
元素:
<xsd:sequence>
<xsd:element name=3D"class" type=3D"tns:classType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
</xsd:complexType>
<xsd:complexType name=3D"classType">
<xsd:documentation>
<xsd:sequence> </xsd:sequence>
<xsd:attribute name=3D"name" type=3D"xsd:string" use=3D"required"/>
<xsd:complexType name=3D"namespaceMappingRegistryType">
<xsd:annotation>
将XML命名空间映射到Java包(以及从Java包映射到XML命名空间)的注册表。
<xsd:sequence>
<xsd:element name=3D"namespaceMapping" type=3D"tns:namespaceMappingType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name=3D"namespaceMappingType">
<xsd:documentation>
<xsd:sequence>
</xsd:sequence>
<xsd:attribute name=3D"namespace" type=3D"xsd:anyURI" use=3D"required"/>
<xsd:attribute name=3D"packageName" type=3D"xsd:string" use=3D"required"/>
</xsd:schema>
XML Schema用于部署描述文件
下面的代码是用于创建Web service 部署描述文件的XML模式:
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema"
xmlns:tns=3D"http://java.sun.com/xml/ns/jax-rpc/ri/dd"
targetNamespace=3D"http://java.sun.com/xml/ns/jax-rpc/ri= /dd"
elementFormDefault=3D"qualified"
attributeFormDefault=3D"unqualified"
<xsd:annotation>
<xsd:documentation>
<xsd:element name=3D"webServices">
<xsd:documentation>
"targetNamespaceBase"? ——WSDL文档的thetargetNamespace的基础URI,该WSDL文档是为那些没有自己的模型文件的端点而生成的;
"typeNamespaceBase"? ——类似于"targetNamespaceBase",但是用于嵌 入在已生成的WSDL 文档中的XML Schema文档;
"urlPatternBase"? ——用于所有端点的基础 URL式样(pattern);通过使用和"endpointMapping(端点映射)",它能够被重载 (见下文)。
对于所有这些基础特性,用于特定端点的值可以由带有追加到它的端点名的基础值来指定。
<xsd:sequence>
<xsd:element name=3D"endpoint" type=3D"tns:endpointType"minOccurs=3D"0" maxOccurs=3D"unbounded"/>
<xsd:element name=3D"endpointMapping"type=3D"tns:endpointMappingType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
</xsd:sequence>
<xsd:attribute name=3D"version" type=3D"xsd:string"use=3D"required"/>
<xsd:attribute name=3D"targetNamespaceBase" type=3D"xsd:string"/>
<xsd:attribute name=3D"typeNamespaceBase" type=3D"xsd:string"/>
<xsd:attribute name=3D"urlPatternBase" type=3D"xsd:string"/>
</xsd:element>
<xsd:complexType name=3D"endpointType">
<xsd:documentation>
元素:
<xsd:sequence>
<xsd:element name=3D"handlerChains" type=3D"tns:handlerChainsType" minOccurs=3D"0"/>
<xsd:attribute name=3D"name" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"displayName" type=3D"xsd:string"/>
<xsd:attribute name=3D"description" type=3D"xsd:string"/>
<xsd:attribute name=3D"interface" type=3D"xsd:string"/>
<xsd:attribute name=3D"implementation" type=3D"xsd:string"/>
<xsd:attribute name=3D"model" type=3D"xsd:anyURI"/>
<xsd:complexType name=3D"endpointMappingType">
<xsd:documentation>
属性:
"urlPattern" —— 端点的URL式样(pattern)。
<xsd:sequence>
</xsd:sequence>
<xsd:attribute name=3D"endpointName" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"urlPattern" type=3D"xsd:string" use=3D"required"/>
<xsd:complexType name=3D"handlerChainsType">
<xsd:documentation>
一组handlerChains。在部署描述文件中,只有server端的处理程序链能够识别。
<xsd:sequence>
<xsd:element name=3D"chain" type=3D"tns:chainType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
</xsd:complexType>
<xsd:complexType name=3D"chainType">
xsd:documentation>
<xsd:sequence>
<xsd:element name=3D"handler" type=3D"tns:handlerType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
</xsd:sequence>
<xsd:attribute name=3D"runAt" type=3D"tns:runAtType" use=3D"required"/>
<xsd:attribute name=3D"roles" type=3D"tns:roleListType"/>
<xsd:simpleType name=3D"roleListType">
<xsd:documentation>
<xsd:list itemType=3D"xsd:anyURI"/>
<xsd:complexType name=3D"handlerType">
<xsd:documentation>
<xsd:sequence>
<xsd:element name=3D"property" type=3D"tns:propertyType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
</xsd:sequence>
<xsd:attribute name=3D"className" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"headers" type=3D"tns:headerListType"/>
<xsd:simpleType name=3D"headerListType">
<xsd:documentation>
<xsd:list itemType=3D"xsd:QName"/>
<xsd:complexType name=3D"propertyType">
<xsd:documentation>
<xsd:sequence>
</xsd:sequence>
<xsd:attribute name=3D"name" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"value" type=3D"xsd:string" use=3D"required"/>
<xsd:simpleType name =3D"runAtType">
<xsd:documentation>
</xsd:documentation>
<xsd:restriction base=3D"xsd:string">
<xsd:enumeration value=3D"client"/>
<xsd:enumeration value=3D"server"/>
</xsd:simpleType>
XML Schema用于已导出的的wscompile模型文件
下面代码是已导出的的wscompile模型文件的XML模式:
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema"
xmlns:tns=3D"http://java.sun.com/xml/ns/jax-rpc/ri/model= "
targetNamespace=3D"http://java.sun.com/xml/ns/jax-rpc/ri= /model"
elementFormDefault=3D"unqualified"
attributeFormDefault=3D"unqualified" version=3D"1.0">
<xsd:documentation>
这是已导出的的wscompile模型文件的XML模式。已导出的模型是对象的图表表示,其中有些是“直接的(immediate)”(比如整型、字符串型),“直接的”对象有一个实际的值。
非直接的对象有一组对象-赋值(object-valued)特性。
<xsd:element name=3D"model" form=3D"qualified">
<xsd:documentation>
</xsd:documentation>
<xsd:complexType>
<xsd:sequence minOccurs=3D"0" maxOccurs=3D"unbounded">
<xsd:element name=3D"object" type=3D"tns:objectType"/>
<xsd:element name=3D"iobject" type=3D"tns:iobjectType"/>
<xsd:element name=3D"property" type=3D"tns:propertyType"/>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name=3D"version" type=3D"xsd:string" use=3D"required"/>
</xsd:element>
<xsd:complexType name=3D"objectType">
<xsd:documentation>
</xsd:documentation>
<xsd:sequence/>
<xsd:attribute name=3D"id" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"type" type=3D"xsd:string" use=3D"required"/>
</xsd:documentation>
<xsd:sequence/>
<xsd:attribute name=3D"id" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"type" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"value" type=3D"xsd:string" use=3D"required"/>
特性定义。也就是说“主题”(由id来识别)有一个称为“name”的特性,将id为“value”的对象作为它的值。
</xsd:documentation>
<xsd:attribute name=3D"name" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"subject" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"value" type=3D"xsd:string" use=3D"required"/>
</xsd:schema>
XML Schema 用于运行时描述文件
<?xml version=3D"1.0" encoding=3D"UTF-8"?>
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema"
xmlns:tns=3D"http://java.sun.com/xml/ns/jax-rpc/ri/runti= me"
targetNamespace=3D"http://java.sun.com/xml/ns/jax-rpc/ri= /runtime"
elementFormDefault=3D"qualified"
attributeFormDefault=3D"unqualified"
<xsd:annotation>
这是运行时描述文件 (jaxrpc-ri-runtime.xml)的模式。
</xsd:documentation>
<xsd:element name=3D"endpoints">
<xsd:complexType>
<xsd:sequence>
<xsd:element name=3D"endpoint" type=3D"tns:endpointType" minOccurs=3D"0" maxOccurs=3D"unbounded"/>
</xsd:sequence>
<xsd:attribute name=3D"version" type=3D"xsd:string" use=3D"required"/>
</xsd:element>
<xsd:complexType name=3D"endpointType">
<xsd:documentation>
"interface" ——端点的Java接口名称 (专业上称为“服务端点接口”);
"service"? —— 属于端点的WSDL服务的QName ;
"port"? —— 用于该端点的WSDL端口的QName;
<xsd:sequence>
</xsd:sequence>
<xsd:attribute name=3D"name" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"interface" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"implementation" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"tie" type=3D"xsd:string" use=3D"required"/>
<xsd:attribute name=3D"model" type=3D"xsd:string"/>
<xsd:attribute name=3D"wsdl" type=3D"xsd:anyURI"/>
<xsd:attribute name=3D"service" type=3D"xsd:anyURI"/>
<xsd:attribute name=3D"port" type=3D"xsd:anyURI"/>
<xsd:attribute name=3D"urlpattern" type=3D"xsd:anyURI" use=3D"required"/>
</xsd:schema>
<script type="text/javascript"> google_ad_client = "pub-8112432724706407"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; google_ad_channel = ""; </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>