我是Spring-WS的新手,我必須爲我的項目創建一個WebService。 因此,嘗試一些例子,我從http://code.google.com/p/spring-webservices-samples/Spring-WS:響應消息包含奇怪的字符
下載了spring-webservices-samples當我部署war文件並使用SoapUI進行測試時;我在響應消息中收到了奇怪的字符(如ce,1a,0),並且「CalculateResponse」元素爲空。
<ns2:CalculateResponse xmlns:ns2='http://www.marvelution.com/samples/schemas/CalculatorServiceSchema'/>
而且沒有例外。我試圖調試,但沒有運氣。
請幫我解決這個問題。我非常感謝任何意見。
我使用JBoss 4.2.3,Java 1.6(64位)。
我試着在Tomcat-7.0.29中部署相同的war文件,它工作。但我必須讓我的WebService在JBoss中使用工作TCPMon的捕獲4.2.3
請求:使用TCPMon的
POST /annotated-payload-endpoint/calculatorService HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "http://www.marvelution.com/samples/definitions/CalculatorService/Add"
Content-Length: 377
Host: 127.0.0.1:9999
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cal="http://www.marvelution.com/samples/schemas/CalculatorServiceSchema">
<soapenv:Header/>
<soapenv:Body>
<cal:Add>
<!--2 or more repetitions:-->
<cal:number>1</cal:number>
<cal:number>2</cal:number>
</cal:Add>
</soapenv:Body>
</soapenv:Envelope>
響應捕獲:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.4; JBoss-4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)/JBossWeb-2.0
SOAPAction: ""
Content-Type: text/xml;charset=UTF-8
Transfer-Encoding: chunked
Date: Fri, 20 Jul 2012 01:47:23 GMT
ce
<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header></env:Header><env:Body><ns2:CalculateResponse xmlns:ns2='http://www.marvelution.com/samples/schemas/CalculatorServiceSchema'/>
1a
</env:Body></env:Envelope>
0
端點:CalculatorEndpoint。 java
@PayloadRoot(namespace = "http://www.marvelution.com/samples/schemas/CalculatorServiceSchema", localPart = "Add")
public CalculateResponse add(Add numbers) {
CalculateResponse res = wrapResult(calculator.add(numbers.getNumber()));
System.out.println("Response before sending:"+res.getResult());
return res;
}
返回響應之前的System.out.println正在打印。我不確定這些字符在哪裏被添加以及爲什麼響應不完整。
感謝, JEG