读书人

WebService CXF SOAP根本结构

发布时间: 2012-09-03 09:48:39 作者: rapoo

WebService CXF SOAP基本结构

SOAP 1.1 被提交到 W3CJava代码?WebService CXF SOAP根本结构

  1. <?xml?version="1.0"?>?????
  2. <soap:Envelope?????
  3. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"????
  4. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">?????
  5. ????
  6. <soap:Header>?????
  7. ??...?????
  8. ??...?????
  9. </soap:Header>?????
  10. ????
  11. <soap:Body>?????
  12. ??...?????
  13. ??...?????
  14. ??<soap:Fault>?????
  15. ????...?????
  16. ????...?????
  17. ??</soap:Fault>?????
  18. </soap:Body>?????
  19. ????
  20. </soap:Envelope>????
  21. ??
  22. <?xml?version="1.0"?>??
  23. <soap:Envelope??
  24. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"??
  25. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">??
  26. ??
  27. <soap:Header>??
  28. ??...??
  29. ??...??
  30. </soap:Header>??
  31. ??
  32. <soap:Body>??
  33. ??...??
  34. ??...??
  35. ??<soap:Fault>??
  36. ????...??
  37. ????...??
  38. ??</soap:Fault>??
  39. </soap:Body>??
  40. ??
  41. </soap:Envelope>??

SOAP Envelope 元素Java代码?WebService CXF SOAP根本结构
  1. <?xml?version="1.0"?>?????
  2. <soap:Envelope?????
  3. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"????
  4. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">?????
  5. ??...?????
  6. ??Message?information?goes?here?????
  7. ??...?????
  8. </soap:Envelope>????
  9. ??
  10. <?xml?version="1.0"?>??
  11. <soap:Envelope??
  12. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"??
  13. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">??
  14. ??...??
  15. ??Message?information?goes?here??
  16. ??...??
  17. </soap:Envelope>??

xmlns:soap 命名空间Java代码?WebService CXF SOAP根本结构
  1. soap:encodingStyle="URI"??
?Java代码?WebService CXF SOAP根本结构
  1. <?xml?version="1.0"?>?????
  2. <soap:Envelope?????
  3. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"????
  4. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">?????
  5. ...?????
  6. Message?information?goes?here?????
  7. ...?????
  8. </soap:Envelope>????
  9. ??
  10. <?xml?version="1.0"?>??
  11. <soap:Envelope??
  12. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"??
  13. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">??
  14. ...??
  15. Message?information?goes?here??
  16. ...??
  17. </soap:Envelope>??


SOAP Header 元素Java代码?WebService CXF SOAP根本结构
  1. <?xml?version="1.0"?>?????
  2. <soap:Envelope?????
  3. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"????
  4. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">?????
  5. ????
  6. <soap:Header>?????
  7. <m:Trans?????
  8. xmlns:m="http://www.w3school.com.cn/transaction/"????
  9. soap:mustUnderstand="1">234</m:Trans>?????
  10. </soap:Header>?????
  11. ????
  12. ...?????
  13. ...?????
  14. ????
  15. </soap:Envelope>????
  16. ??
  17. <?xml?version="1.0"?>??
  18. <soap:Envelope??
  19. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"??
  20. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">??
  21. ??
  22. <soap:Header>??
  23. <m:Trans??
  24. xmlns:m="http://www.w3school.com.cn/transaction/"??
  25. soap:mustUnderstand="1">234</m:Trans>??
  26. </soap:Header>??
  27. ??
  28. ...??
  29. ...??
  30. ??
  31. </soap:Envelope>??

??? 上面的例子包含了一个带有一个 "Trans" 元素的头部,它的值是 234,此元素的 "mustUnderstand" 属性的值是 "1"。Java代码?WebService CXF SOAP根本结构
  1. soap:actor="URI"???
?Java代码?WebService CXF SOAP根本结构
  1. <?xml?version="1.0"?>?????
  2. <soap:Envelope?????
  3. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"????
  4. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">?????
  5. ????
  6. <soap:Header>?????
  7. <m:Trans?????
  8. xmlns:m="http://www.w3school.com.cn/transaction/"????
  9. soap:actor="http://www.w3school.com.cn/appml/">?????
  10. 234????
  11. </m:Trans>?????
  12. </soap:Header>?????
  13. ????
  14. ...?????
  15. ...?????
  16. ????
  17. </soap:Envelope>????
  18. ??
  19. <?xml?version="1.0"?>??
  20. <soap:Envelope??
  21. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"??
  22. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">??
  23. ??
  24. <soap:Header>??
  25. <m:Trans??
  26. xmlns:m="http://www.w3school.com.cn/transaction/"??
  27. soap:actor="http://www.w3school.com.cn/appml/">??
  28. 234??
  29. </m:Trans>??
  30. </soap:Header>??
  31. ??
  32. ...??
  33. ...??
  34. ??
  35. </soap:Envelope>??

mustUnderstand 属性Java代码?WebService CXF SOAP根本结构
  1. soap:mustUnderstand="0|1"???


soap:mustUnderstand="0|1"Java代码?WebService CXF SOAP根本结构
  1. <?xml?version="1.0"?>?????
  2. <soap:Envelope?????
  3. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"????
  4. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">?????
  5. ????
  6. <soap:Header>?????
  7. <m:Trans?????
  8. xmlns:m="http://www.w3school.com.cn/transaction/"????
  9. soap:mustUnderstand="1">?????
  10. 234????
  11. </m:Trans>?????
  12. </soap:Header>?????
  13. ????
  14. ...?????
  15. ...?????
  16. ????
  17. </soap:Envelope>????
  18. ??
  19. <?xml?version="1.0"?>??
  20. <soap:Envelope??
  21. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"??
  22. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">??
  23. ??
  24. <soap:Header>??
  25. <m:Trans??
  26. xmlns:m="http://www.w3school.com.cn/transaction/"??
  27. soap:mustUnderstand="1">??
  28. 234??
  29. </m:Trans>??
  30. </soap:Header>??
  31. ??
  32. ...??
  33. ...??
  34. ??
  35. </soap:Envelope>??

encodingStyle 属性Java代码?WebService CXF SOAP根本结构
  1. <?xml?version="1.0"?>?????
  2. <soap:Envelope?????
  3. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"????
  4. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">?????
  5. ????
  6. <soap:Body>?????
  7. ???<m:GetPrice?xmlns:m="http://www.w3school.com.cn/prices">?????
  8. ??????<m:Item>Apples</m:Item>?????
  9. ???</m:GetPrice>?????
  10. </soap:Body>?????
  11. ????
  12. </soap:Envelope>????
  13. ??
  14. <?xml?version="1.0"?>??
  15. <soap:Envelope??
  16. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"??
  17. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">??
  18. ??
  19. <soap:Body>??
  20. ???<m:GetPrice?xmlns:m="http://www.w3school.com.cn/prices">??
  21. ??????<m:Item>Apples</m:Item>??
  22. ???</m:GetPrice>??
  23. </soap:Body>??
  24. ??
  25. </soap:Envelope>??

?? 上面的例子请求苹果的价格。请注意,上面的 m:GetPrice 和 Item 元素是应用程序专用的元素。它们并不是 SOAP 标准的一部分。Java代码?WebService CXF SOAP根本结构
  1. <?xml?version="1.0"?>?????
  2. <soap:Envelope?????
  3. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"????
  4. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">?????
  5. ????
  6. <soap:Body>?????
  7. ???<m:GetPriceResponse?xmlns:m="http://www.w3school.com.cn/prices">?????
  8. ??????<m:Price>1.90</m:Price>?????
  9. ???</m:GetPriceResponse>?????
  10. </soap:Body>?????
  11. ????
  12. </soap:Envelope>????
  13. ??
  14. <?xml?version="1.0"?>??
  15. <soap:Envelope??
  16. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"??
  17. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">??
  18. ??
  19. <soap:Body>??
  20. ???<m:GetPriceResponse?xmlns:m="http://www.w3school.com.cn/prices">??
  21. ??????<m:Price>1.90</m:Price>??
  22. ???</m:GetPriceResponse>??
  23. </soap:Body>??
  24. ??
  25. </soap:Envelope>??

SOAP Fault 元素子元素????????描述???????????<faultcode>?供识别故障的代码<faultstring>可供人阅读的有关故障的说明<faultactor>有关是谁引发故障的信息????<detail>????存留涉及 Body 元素的应用程序专用错误信息



SOAP Fault Codes错误?描述?VersionMismatchSOAP Envelope 元素的无效命名空间被发现MustUnderstandHeader 元素的一个直接子元素(带有设置为 "1" 的mustUnderstand 属性)无法被理解。Client?消息被不正确地构成,或包含了不正确的信息。?Server?服务器有问题,因此无法处理进行下去。?

HTTP 协议Java代码?WebService CXF SOAP根本结构
  1. POST?/item?HTTP/1.1????
  2. Host:?189.123.345.239????
  3. Content-Type:?text/plain?????
  4. Content-Length:?200????
  5. ??
  6. POST?/item?HTTP/1.1??
  7. Host:?189.123.345.239??
  8. Content-Type:?text/plain??
  9. Content-Length:?200??
?Java代码?WebService CXF SOAP根本结构
  1. 200?OK?????
  2. Content-Type:?text/plain?????
  3. Content-Length:?200????
  4. ??
  5. 200?OK??
  6. Content-Type:?text/plain??
  7. Content-Length:?200??

? 在上面的例子中,服务器返回了一个 200 的状态代码。这是 HTTP 的标准成功代码。Java代码?WebService CXF SOAP根本结构
  1. 400?Bad?Request?????
  2. Content-Length:?0????
  3. ??
  4. 400?Bad?Request??
  5. Content-Length:?0??



SOAP HTTP BindingJava代码?WebService CXF SOAP根本结构
  1. Content-Type:?MIMEType;?charset=character-encoding?????

Content-Type: MIMEType; charset=character-encodingJava代码?WebService CXF SOAP根本结构
  1. POST?/item?HTTP/1.1????
  2. Content-Type:?application/soap+xml;?charset=utf-8????
  3. ??
  4. POST?/item?HTTP/1.1??
  5. Content-Type:?application/soap+xml;?charset=utf-8??


Content-LengthJava代码?WebService CXF SOAP根本结构
  1. Content-Length:?bytes???


Content-Length: bytesJava代码?WebService CXF SOAP根本结构
  1. POST?/item?HTTP/1.1????
  2. Content-Type:?application/soap+xml;?charset=utf-8????
  3. Content-Length:?250????

POST /item HTTP/1.1Java代码?WebService CXF SOAP根本结构
  1. POST?/InStock?HTTP/1.1????
  2. Host:?www.example.org?????
  3. Content-Type:?application/soap+xml;?charset=utf-8????
  4. Content-Length:?nnn?????
  5. ????
  6. <?xml?version="1.0"?>?????
  7. <soap:Envelope?????
  8. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"????
  9. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">?????
  10. ????
  11. ??<soap:Body?xmlns:m="http://www.example.org/stock">?????
  12. ????<m:GetStockPrice>?????
  13. ??????<m:StockName>IBM</m:StockName>?????
  14. ????</m:GetStockPrice>?????
  15. ??</soap:Body>?????
  16. ???????
  17. </soap:Envelope>????
  18. ??
  19. POST?/InStock?HTTP/1.1??
  20. Host:?www.example.org??
  21. Content-Type:?application/soap+xml;?charset=utf-8??
  22. Content-Length:?nnn??
  23. ??
  24. <?xml?version="1.0"?>??
  25. <soap:Envelope??
  26. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"??
  27. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">??
  28. ??
  29. ??<soap:Body?xmlns:m="http://www.example.org/stock">??
  30. ????<m:GetStockPrice>??
  31. ??????<m:StockName>IBM</m:StockName>??
  32. ????</m:GetStockPrice>??
  33. ??</soap:Body>??
  34. ????
  35. </soap:Envelope>??

SOAP 响应:Java代码?WebService CXF SOAP根本结构
  1. HTTP/1.1?200?OK?????
  2. Content-Type:?application/soap+xml;?charset=utf-8????
  3. Content-Length:?nnn?????
  4. ????
  5. <?xml?version="1.0"?>?????
  6. <soap:Envelope?????
  7. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"????
  8. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">?????
  9. ????
  10. ??<soap:Body?xmlns:m="http://www.example.org/stock">?????
  11. ????<m:GetStockPriceResponse>?????
  12. ??????<m:Price>34.5</m:Price>?????
  13. ????</m:GetStockPriceResponse>?????
  14. ??</soap:Body>?????
  15. ???????
  16. </soap:Envelope>????

原文:http://yakar.iteye.com/blog/968930

读书人网 >Web前端

热点推荐