CXF代理Web服务
我是JavaServlet过滤器的新手,我有一个CXFWeb服务a A的地址是: 我想实现一个代理web服务B B的地址是: 为了将请求转发到A到B,我在B中添加了一个servlet过滤器:CXF代理Web服务,web,service,proxy,cxf,Web,Service,Proxy,Cxf,我是JavaServlet过滤器的新手,我有一个CXFWeb服务a A的地址是: 我想实现一个代理web服务B B的地址是: 为了将请求转发到A到B,我在B中添加了一个servlet过滤器: public class RequestFilter implements Filter { public void doFilter(final ServletRequest request, final ServletResponse response, FilterChain chain)
public class RequestFilter implements Filter {
public void doFilter(final ServletRequest request, final ServletResponse response, FilterChain chain)
throws java.io.IOException, javax.servlet.ServletException {
HttpServletResponse resp = (HttpServletResponse) response;
String redirect="http://localhost:8080/AdditionWS/services/additioncls";
Enumeration<String> enumeration=request.getParameterNames();
String parameter=null;
while(enumeration.hasMoreElements())
{
parameter=enumeration.nextElement();
if(parameter.toLowerCase()=="wsdl")
break;
}
// if the parameter 'wsdl' exists forward to http://localhost:8080/AdditionWS/services/additioncls?wsdl
if(parameter!=null)
redirect="http://localhost:8080/AdditionWS/services/additioncls?"+"wsdl";
redirect=resp.encodeRedirectURL(redirect);
resp.sendRedirect(redirect);
}
}
由于某些原因,客户端请求未转发到,我收到以下错误:
Exception in thread "main" javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:162)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:129)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:82)
at javax.xml.ws.Service.<init>(Service.java:77)
at business.AdditionClsService.<init>(AdditionClsService.java:43)
at business.AdditionWSSEI_AdditionClsPort_Client.main(AdditionWSSEI_AdditionClsPort_Client.java:49)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:87)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:217)
at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:160)
... 5 more
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col,system-id]: [1,0,"http://localhost:8080/ForwardWS/services/ForwardClsPort?wsdl"]
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:228)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:163)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:85)
... 7 more
Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col,system-id]: [1,0,"http://localhost:8080/ForwardWS/services/ForwardClsPort?wsdl"]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:685)
at com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2141)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2047)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1131)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1369)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1263)
at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1191)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:219)
... 9 more
线程“main”javax.xml.ws.webserviceception中的异常:org.apache.cxf.service.factory.ServiceConstructionException:未能创建服务。
在org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:162)上
位于org.apache.cxf.jaxws.serviceinpl.(serviceinpl.java:129)
位于org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:82)
位于javax.xml.ws.Service。(Service.java:77)
在business.AdditionClsService.(AdditionClsService.java:43)
在business.AdditionWSSEI_AdditionClsPort_Client.main(AdditionWSSEI_AdditionClsPort_Client.java:49)
原因:org.apache.cxf.service.factory.ServiceConstructionException:未能创建服务。
位于org.apache.cxf.wsdl11.WSDLServiceFactory.(WSDLServiceFactory.java:87)
位于org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:217)
在org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:160)上
... 还有5个
原因:javax.wsdl.WSDLException:WSDLException:faultCode=PARSER_错误:com.ctc.wstx.exc.WstxEOFException:prolog中意外的EOF
在[行,列,系统id]:[1,0,”http://localhost:8080/ForwardWS/services/ForwardClsPort?wsdl"]
位于org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:228)
位于org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:163)
位于org.apache.cxf.wsdl11.WSDLServiceFactory.(WSDLServiceFactory.java:85)
... 还有7个
原因:com.ctc.wstx.exc.wstxeof异常:prolog中出现意外EOF
在[行,列,系统id]:[1,0,”http://localhost:8080/ForwardWS/services/ForwardClsPort?wsdl"]
位于com.ctc.wstx.sr.StreamScanner.throwunnexpectedeof(StreamScanner.java:685)
位于com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2141)
位于com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2047)
位于com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1131)
位于org.apache.cxf.staxutils.staxutils.readDocElements(staxutils.java:1369)
位于org.apache.cxf.staxutils.staxutils.readDocElements(staxutils.java:1263)
位于org.apache.cxf.staxutils.staxutils.read(staxutils.java:1191)
位于org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:219)
... 9更多
我是否遗漏了什么,或者是否有其他方法来实现代理cxf web服务,该服务将客户端请求转发给一个或多个副本?
谢谢大家!
Exception in thread "main" javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:162)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:129)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:82)
at javax.xml.ws.Service.<init>(Service.java:77)
at business.AdditionClsService.<init>(AdditionClsService.java:43)
at business.AdditionWSSEI_AdditionClsPort_Client.main(AdditionWSSEI_AdditionClsPort_Client.java:49)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:87)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:217)
at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:160)
... 5 more
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col,system-id]: [1,0,"http://localhost:8080/ForwardWS/services/ForwardClsPort?wsdl"]
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:228)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:163)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:85)
... 7 more
Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col,system-id]: [1,0,"http://localhost:8080/ForwardWS/services/ForwardClsPort?wsdl"]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:685)
at com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2141)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2047)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1131)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1369)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1263)
at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1191)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:219)
... 9 more