CXF報錯後,獨立解決->unwinding now Response was of unexpected text/html ContentType.

我的一個cxf項目, 在修改了web.xml的url-pattern後,調用報錯,如下:

 

2009-12-8 10:09:00 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
信息: Interceptor has thrown exception, unwinding now Response was of unexpected text/html ContentType.  Incoming portion of HTML stream: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><HTML><HEAD><LINK type="text/css" rel="stylesheet" href="/terminal/TermWebservice/?stylesheet=1"><meta http-equiv=content-type content="text/html; charset=UTF-8"><title>CXF - Service list</title></head><body><span class="heading">Available services:</span><br/><table cellpadding="1" cellspacing="1" border="1" width="100%"><tr><td><span class="porttypename">TermWebservice</span><ul><li>getTermXml</li><li>getTermList</li></ul></td><td><span class="field">Endpoint address:</span> <span class="value">http://localhost:8088/terminal/TermWebservice/TermWebservice</span><br/><span class="field">Wsdl:</span> <a href="http://localhost:8088/terminal/TermWebservice/TermWebservice?wsdl">{http://webservice.terminalmonitor.synjones.com/}TermWebserviceImplService</a><br/><span class="field">Target namespace:</span> <span class="value">http://webservice.terminalmonitor.synjones.com/</span></td></tr></table></body></html>
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Response was of unexpected text/html ContentType.  Incoming portion of HTML stream: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><HTML><HEAD><LINK type="text/css" rel="stylesheet" href="/terminal/TermWebservice/?stylesheet=1"><meta http-equiv=content-type content="text/html; charset=UTF-8"><title>CXF - Service list</title></head><body><span class="heading">Available services:</span><br/><table cellpadding="1" cellspacing="1" border="1" width="100%"><tr><td><span class="porttypename">TermWebservice</span><ul><li>getTermXml</li><li>getTermList</li></ul></td><td><span class="field">Endpoint address:</span> <span class="value">http://localhost:8088/terminal/TermWebservice/TermWebservice</span><br/><span class="field">Wsdl:</span> <a href="http://localhost:8088/terminal/TermWebservice/TermWebservice?wsdl">{http://webservice.terminalmonitor.synjones.com/}TermWebserviceImplService</a><br/><span class="field">Target namespace:</span> <span class="value">http://webservice.terminalmonitor.synjones.com/</span></td></tr></table></body></html>
 at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:145)
 at $Proxy43.getTermList(Unknown Source)
 at com.synjones.terminalmonitor.webservice.client.Client.main(Client.java:26)
Caused by: org.apache.cxf.interceptor.Fault: Response was of unexpected text/html ContentType.  Incoming portion of HTML stream: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><HTML><HEAD><LINK type="text/css" rel="stylesheet" href="/terminal/TermWebservice/?stylesheet=1"><meta http-equiv=content-type content="text/html; charset=UTF-8"><title>CXF - Service list</title></head><body><span class="heading">Available services:</span><br/><table cellpadding="1" cellspacing="1" border="1" width="100%"><tr><td><span class="porttypename">TermWebservice</span><ul><li>getTermXml</li><li>getTermList</li></ul></td><td><span class="field">Endpoint address:</span> <span class="value">http://localhost:8088/terminal/TermWebservice/TermWebservice</span><br/><span class="field">Wsdl:</span> <a href="http://localhost:8088/terminal/TermWebservice/TermWebservice?wsdl">{http://webservice.terminalmonitor.synjones.com/}TermWebserviceImplService</a><br/><span class="field">Target namespace:</span> <span class="value">http://webservice.terminalmonitor.synjones.com/</span></td></tr></table></body></html>
 at org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(StaxInInterceptor.java:73)
 at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:226)
 at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:641)
 at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2102)
 at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1980)
 at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1905)
 at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
 at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:600)
 at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
 at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:226)
 at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:469)
 at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:299)
 at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:251)
 at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
 at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)
 ... 2 more

 

 

主要是本人對錯誤描述不得要領, google一下關鍵信息: Interceptor has thrown exception, unwinding now Response was of unexpected text/html ContentType.  但是沒有找到滿意答案, 後來一看,提示的信息裏有http://localhost:8088/terminal/TermWebservice/TermWebservice?wsdl, 這個url比我配置的多了一個TermWebservice

就是我剛剛多配置的web.xml的url-pattern,爲<url-pattern>/TermWebservice/*</url-pattern>, 了以前是<url-pattern>/*</url-pattern> 的, 所以問題找到了, 是url要多加一個TermWebservice,

      所以在調用的client端,加上TermWebservice這樣在調用就可以了, 因爲錯誤比較誤導人,而網上查詢有沒有, 希望能幫到有同樣錯誤的兄弟。

發佈了36 篇原創文章 · 獲贊 2 · 訪問量 15萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章