[WebService]之Schema

schema入门

1:schema出现的目的是通过一个更加合理的方式来编写xml文件的限制(以XML语法的方式)

2:schema可以使用命名空间来支持多个名称相同的元素

3:schema可以很好的的完成对JAVA或者所有的对象的修饰并且提供了大量的数据类型

<?xml version="1.0" encoding="UTF-8"?>
<!-- schema xmlns:xsd="http://www.w3.org/2001/XMLSchema 表示schema的命名空间,不能改动,为它定义命名空间为xsd,以后的元素必须为xsd才能使用 -->
<!-- targetNamespace="http://www.example.org/01" 被其它地方引用的名称 -->
<!-- xmlns:tns="http://www.example.org/01" 默认命名空间,只能有一个不加前缀 -->
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/01"
    xmlns:tns="http://www.example.org/01" elementFormDefault="qualified">
    <element name="user">
        <complexType>
            <sequence>
                <element name="id" type="int"></element>
                <element name="username" type="string"></element>
                <element name="born" type="date"></element>
            </sequence>
        </complexType>
    </element>
</schema>

验证方式一:

<?xml version="1.0" encoding="UTF-8"?>
<user xmlns="http://www.example.org/01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.example.org/01">
    <id>1</id>
    <username>admin</username>
    <born>1986-07-20</born>
</user>

验证方式二:

<?xml version="1.0" encoding="UTF-8"?>
<user xmlns="http://www.example.org/01" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="01.xsd">
    <id>1</id>
    <username>admin</username>
    <born>1986-07-20</born>
</user>

总结:

时间: 2024-08-05 13:29:11

[WebService]之Schema的相关文章

WebService笔记-Schema约束

                    Schema约束 俗话说得好 好记性不如烂笔头. 看了下WebService视频,觉得还是得下笔记. 观看的视频地址:http://edu.51cto.com/lesson/id-25757.html 复习下xml约束  bool.xsd是book.xml的约束文档 1 <schema xmlns="http://www.w3.org/2001/XMLSchema" 2 targetNamespace="http://www.at

Web环境使用相对路径发布Webservice

常我们的Webservice服务的发布地址都将是一个相对路径,在与Spring一起使用时我们需要引入Cxf配置Webservice的schema,如jaxws,用以定义对应的Webservice. <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="htt

Wrapper class webservice.jaxws.SayHi is not found. Have you run APT to generate them?

最近在研究webservice,利用jdk来实现简单的webservice发布,但是运行时却发生了这样的异常,如下: Exception in thread "main" com.sun.xml.internal.ws.model.RuntimeModelerException: runtime modeler error: Wrapper class webservice.jaxws.SayHi is not found. Have you run APT to generate t

SOAP/Web Service/WSDL关系

转载----------------------------------------------- 最近看了xml schema,xpah,和xslt的相关内容,感觉wsdl就是一个soap的schema,一个soap就是一个wsdl的实例,实际上wsdl就是整个webservice的schema. 从这个角度看,要学好soap,不如从xml schema开始,然后转到wsdl的学习,这样webservice就没有其他理论上的东西可学了.就剩下类库内的函数如何使用的问题了. 对SOAP/Web

WebService学习笔记-XML&Schema&HTTP

XML约束 在XML技术里,可以编写一个文档(文件)来约束一个XML文档的书写规范,这称之为XML约束 1.namespace 相当于schema文件的id 2.targetNamespace属性 用来指定schema文件的namespace的值 3.xmlns属性 引入一个约束, 它的值是一个schema文件的namespace值 4.schemaLocation属性 用来指定引入的schema文件的位置 schema规范中: 1. 所有标签和属性都需要有schema文件来定义 2. 所有的s

WebService . Schema约束

1. namespace 相当于schema文件的id 2. targetNamespace属性 用来指定schema文件的namespace的值 3. xmlns属性 引入一个约束, 它的值是一个schema文件的namespace值 4. schemaLocation属性 用来指定引入的schema文件的位置   schema规范中: 1. 所有标签和属性都需要有schema文件来定义 2. 所有的schema文件都需要有一个id, 但在这里它叫namespace, 3. namespace

spring 与 CXF 整合 webservice 出现error “Unable to locate Spring NamespaceHandler for XML schema namespace” 总结

我试了多个版本的spring 发现 出现error : Unable to locate Spring NamespaceHandler for XML schema namespace 并非都是spring.schemas 和 spring.handlers 两个文件覆盖缺少等造成的问题. 出现error原因: spring 版本 通过cxf 自带的spring jar包看来  只与最稳当的spring.3.0.5 兼容.所以在整合spring 与 cxf 的时候, 最后不要自己去另外加spr

webservice实验一

实验目的:安装jdk1.6_21以后的版本,利用JAX-WS API自己发布webservice并调用,以及用wsimport生成webservice客户端代码调用一个免费的web服务(如webxml.com.cn上的获取手机归属地的服务). 一.webservice原理了解 webservice是一种通用的跨语言跨平台的数据交互方式,之所以能够做到这一点,是因为它的底层实现机制是依赖于HTTP协议以及XML格式这些开发的标准.webservice使用SOAP(simple object acc

CXF框架实现webservice实例

服务器端: 1.新建Web项目,例如CXF_Server,导入cxf-2.4.2的相关jar包,如下图所示: 2.新建一个webservice服务接口MyService,该接口通过注解来暴露服务:  package com.founder.service; import javax.jws.WebService; @WebService(serviceName="MyServiceManage") public interface MyService { /**  * add():定义