08_使用TCP/IP Monitor监视SOAP协议

【SOAP定义】

SOAP   简单对象访问协议,基于http传输xml数据,soap协议体是xml格式。
SOAP   是一种网络通信协议
SOAP   即Simple Object Access Protocol简易对象访问协议
SOAP   用于跨平台应用程序之间的通信
SOAP   被设计用来通过因特网(http)进行通信
SOAP   = HTTP+XML,其实就是通过HTTP发xml数据
SOAP   很简单并可扩展支持面向对象
SOAP   允许跨越防火墙
SOAP   将被作为 W3C 标准来发展

【TCP/IP Monitor】

TCP/IP Monitor:是eclipse自带的一个工具,通过代理的方法监视tcp协议内容。

通过TCP/IP Monitor监视soap协议内容。

【Eclipse配置TCP/IP Monitor】

1.[ Window ]----->[ Show View ]----->[ Other ] ----->搜索"TCP",双击“TCP/IP Monitor”

2.在下方的“TCP/IP Monitor”中,鼠标右键点"Properties"

 

3.出现了以下界面,点击"Add",填写以下信息,点击“OK”,就启动了TCP/IP Monitor

 【测试】

【运行结果】

测试本地的天气查询,启动服务端之后,查看浏览器,相当于进入了127.0.0.1:12345/weather

然后看控制台的运行结果

查看TCP/IP Monitor也有数据

 【分析】

1.客户端请求的SOAP内容

POST /weather HTTP/1.1
Accept: text/xml, multipart/related
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://server.weather.jaxws.Higgin.com/WeatherInterfaceImpl/queryWeatherRequest"
User-Agent: JAX-WS RI 2.2.4-b01
Host: 127.0.0.1:54321
Connection: keep-alive
Content-Length: 224

SOAP协议体的内容

<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns2:queryWeather xmlns:ns2="http://server.weather.jaxws.Higgin.com/">
            <arg0>北京</arg0>  <!-- 请求的参数 -->
        </ns2:queryWeather>
    </S:Body>
</S:Envelope>

SOAP协议体包含下列元素:

[ 必须有的 ]

Envelop元素:此元素将整个XML文档标识为一条SOAP消息

Body元素:包含所有的调用和相应信息

[ 可选的 ]

Header元素:包含头信息

Fault元素:提供有关在处理此消息所发生的错误

【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>
原文地址:https://www.cnblogs.com/HigginCui/p/5834365.html