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这样在调用就可以了, 因为错误比较误导人,而网上查询有没有, 希望能帮到有同样错误的兄弟。

你可能感兴趣的:(html,exception,Stream,Interceptor,Class,stylesheet)