我使用JAX-WS和My Eclipse开发了一个简单的Web服务项目。应用程序正常。但是,如果我在My eclipse IDE中看到TCP / IP监视器。
请求&回复显示如下:
请求部分:
GET /webservices/demo?wsdl HTTP/1.1
User-Agent: Java/1.7.0_80-ea
Host: localhost:7211
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
POST /webservices/demo HTTP/1.1
Accept: text/xml, multipart/related
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://webservice.java.ram.com/DemoService/getNameLenghtRequest"
User-Agent: JAX-WS RI 2.2.8-promoted-b146 svn-revision#13443
Host: localhost:7211
Connection: keep-alive
Content-Length: 262
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:getNameLenght xmlns:ns2="http://webservice.java.ram.com/"><user><name>RAMK</name><pass>pass</pass></user></ns2:getNameLenght></S:Body></S:Envelope>
响应部分:
HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: text/xml;charset=utf-8
Date: Thu, 14 Jan 2016 04:31:44 GMT
696
<?xml version='1.0' encoding='UTF-8'?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.8-promoted-b146 svn-revision#13443. --><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.8-promoted-b146 svn-revision#13443. --><definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://ws.webservice.java.ram.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://ws.webservice.java.ram.com/" name="DemoServiceWSService">
<import namespace="http://webservice.java.ram.com/" location="http://localhost:7211/webservices/demo?wsdl=1"/>
<binding xmlns:ns1="http://webservice.java.ram.com/" name="DemoServiceWSPortBinding" type="ns1:DemoService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="getNameLenght">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="deleteSpaces">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="DemoServiceWSService">
<port name="DemoServiceWSPort" binding="tns:DemoServiceWSPortBinding">
<soap:address location="http://localhost:7211/webservices/demo"/>
</port>
</service>
</definitions>
0
HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: text/xml; charset=utf-8
Date: Thu, 14 Jan 2016 04:31:46 GMT
6e
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body>
9a
<ns2:getNameLenghtResponse xmlns:ns2="http://webservice.java.ram.com/"><return><count>4</count></return></ns2:getNameLenghtResponse></S:Body></S:Envelope>
0
在这里,我期待的是,我希望以XML格式看到请求消息。但是如您所见,请求/响应不是XML格式。如果我选择XML作为TCP / IP监视器中的视图,TCP / IP监视器将显示请求/响应消息为非结构化。
所以,我的问题是,如何以XML格式准确地获取请求消息。
例如:
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:getNameLenght xmlns:ns2="http://webservice.java.ram.com/"><user><name>RAMK</name><pass>pass</pass></user></ns2:getNameLenght></S:Body></S:Envelope>