---
title: "CXF详解四"
author: "ootabc"
date: "2010-12-31T11:19:41Z"
tags: ["ASP", "SOAP", "XML", "数据结构"]
categories: ["企业架构"]
slug: "cxf"
draft: false
lastmod: "2010-12-31T11:19:41Z"
id: 856666
url: "https://ootabc.iteye.com/blog/856666"
---

# CXF之SOAP

JAX-WS支持soap1.1、soap1.2。

## SOAP 构建模块

一条 SOAP 消息就是一个普通的 XML 文档，包含下列元素：

l  必需的 Envelope 元素，可把此 XML 文档标识为一条 SOAP 消息

l  可选的 Header 元素，包含头部信息

l  必需的 Body 元素，包含所有的调用和响应信息

l  可选的 Fault 元素，提供有关在处理此消息所发生错误的信息

所有以上的元素均被声明于针对 SOAP 封装的默认命名空间中：

[http://www.w3.org/2001/12/soap-envelope](http://www.w3.org/2001/12/soap-envelope "soap-envelope.xml")

以及针对 SOAP 编码和数据类型的默认命名空间：

[http://www.w3.org/2001/12/soap-encoding](http://www.w3.org/2001/12/soap-encoding "soap-encoding.xml")

## 语法规则

这里是一些重要的语法规则：

l  SOAP 消息必须用 XML 来编码

l  SOAP 消息必须使用 SOAP Envelope 命名空间

l  SOAP 消息必须使用 SOAP Encoding 命名空间

l  SOAP 消息不能包含 DTD 引用

l  SOAP 消息不能包含 XML 处理指令

## SOAP 消息的基本结构

## `<?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Header> ... </soap:Header> <soap:Body> ... <soap:Fault> .... </soap:Fault> </soap:Body> </soap:Envelope>`   参考： ²  [http://www.w3school.com.cn/soap/soap\_envelope.asp](http://www.w3school.com.cn/soap/soap_envelope.asp)