指示应使用哪个版本的 XML 模式来解码 XML Web 服务负载的最佳方法是什么? [英] Whats the best way to indicate which version of an XML schema should be used to decode an XML web service payload?

查看:36
本文介绍了指示应使用哪个版本的 XML 模式来解码 XML Web 服务负载的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我主要是在 REST/XML Web 服务 API(媒体类型application/vnd.mystuff+xml")的上下文中问这个问题,但也许这个问题对于基于 SOAP 的 Web 服务仍然有效.

I am asking this question predominantly in the context of a REST/XML web service API (media type "application/vnd.mystuff+xml"), but perhaps the question is still valid for SOAP based web services.

如果描述我们资源/有效负载词汇的 XML 模式发生变化,我应该如何最好地向客户表明他们应该使用/期待更新版本的 XML 模式?

In the event that the XML schema that describes the vocabulary of our resources/payloads changes, how should I best indicate to the client they should use/expect a newer version of the XML schema?

我们是否应该像这样在根元素中包含一个版本标识符:

Should we include a version identifier in the root element like this:

<mything xmlns="http://mycompany.com/yadda" version="1.0">

或者我们应该像这样引用 XML 模式:

or should we just reference the XML schema like this:

<mything  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:SchemaLocation="http://mycompany.com/yadda/1 yadda-1.0.xsd"
          xmlns="http://mycompany.com/yadda">

还是两者兼而有之?

<mything  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:SchemaLocation="http://mycompany.com/yadda/1 yadda-1.0.xsd"
          xmlns="http://mycompany.com/yadda"
          version="1.0">

发送引用 XML 架构的 XML 有效负载是常见做法吗?

Is it common practice to send an XML payload that references an XML schema?

推荐答案

没有.使用 XML 命名空间指定要使用的架构.

No. Use the XML namespace to specify which schema to use.

这篇关于指示应使用哪个版本的 XML 模式来解码 XML Web 服务负载的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆