jaxws wsdl解析问题

时间:2013-03-24 15:01:26

标签: spring wsdl jax-ws

我有一个使用JAX-WS创建的WebService,我编写了一个JUnit,以下列方式连接到它:

public class LicenseSvcClient {


    private static final String WS_URL = "https://dubdubdub.com/licenseService?wsdl";
    private static LicenseService licenseService;

    @BeforeClass
    public static void init() throws MalformedURLException{
        URL url = new URL(WS_URL);
        QName qname = new QName("http://webservices.activation.cellebrite/", "LicenseServiceImplService");
        Service service = Service.create(url, qname);
        licenseService = service.getPort(LicenseService.class);
        Map<String, Object> req_ctx = ((BindingProvider)licenseService).getRequestContext();
        req_ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, WS_URL);

        Map<String, List<String>> headers = new HashMap<String, List<String>>();                

        req_ctx.put(MessageContext.HTTP_REQUEST_HEADERS, headers);

    }

    @Test
    public void lol(){

            licenseService.hasCellewiseLicense("Roflol");
    }

}

这个JUnit非常出色,并且它连接到服务,但是,当我尝试从另一个应用程序连接到此服务时,它会抛出以下异常,请注意我使用完全相同的代码。

[Fatal Error] licenseService?xsd=1:6:3: The element type "hr" must be terminated by the matching end-tag "</hr>".
[Fatal Error] licenseService?xsd=1:6:3: The element type "hr" must be terminated by the matching end-tag "</hr>".
2013-03-24 16:52:41,292 ERROR DefaultExceptionMapper:114 - Unexpected error occurred
org.apache.wicket.WicketRuntimeException: Can't instantiate page using constructor 'public cellebrite.urs.web.page.cellewise.CellewiseCodeGenerationPage()'. Might be it doesn't exist, may be it is not visible (public).
    at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:196)
    at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:68)
    at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:47)
    at org.apache.wicket.DefaultMapperContext.newPageInstance(DefaultMapperContext.java:103)
    at org.apache.wicket.request.handler.PageProvider.resolvePageInstance(PageProvider.java:264)
    at org.apache.wicket.request.handler.PageProvider.getPageInstance(PageProvider.java:165)
    at org.apache.wicket.request.handler.render.PageRenderer.getPage(PageRenderer.java:78)
    at org.apache.wicket.request.handler.render.WebPageRenderer.renderPage(WebPageRenderer.java:105)
    at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:224)
    at org.apache.wicket.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:167)
    at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:784)
    at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
    at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:255)
    at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:212)
    at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:283)
    at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:188)
    at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:244)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)
    at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1115)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:361)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:324)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:534)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:864)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:533)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:207)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:403)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:522)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:177)
    ... 34 more
Caused by: javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
    at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:150)
    at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:91)
    at javax.xml.ws.Service.<init>(Unknown Source)
    at javax.xml.ws.Service.create(Unknown Source)
    at com.cellebrite.shared.webservice.LicenseServiceClient.init(LicenseServiceClient.java:59)
    at com.cellebrite.shared.webservice.LicenseServiceClient.load(LicenseServiceClient.java:79)
    at com.cellebrite.shared.webservice.LicenseServiceClient.isCellewiseEnabled(LicenseServiceClient.java:70)
    at WICKET_com.cellebrite.shared.webservice.LicenseServiceClient$$FastClassByCGLIB$$d8ec55d.invoke(<generated>)
    at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
    at org.apache.wicket.proxy.LazyInitProxyFactory$CGLibInterceptor.intercept(LazyInitProxyFactory.java:318)
    at WICKET_com.cellebrite.shared.webservice.LicenseServiceClient$$EnhancerByCGLIB$$57f3c545.isCellewiseEnabled(<generated>)
    at cellebrite.urs.web.page.cellewise.CellewiseCodeGenerationPage.canAccess(CellewiseCodeGenerationPage.java:49)
    at cellebrite.urs.web.page.cellewise.CellewiseCodeGenerationPage.<init>(CellewiseCodeGenerationPage.java:41)
    ... 39 more
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
    at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:94)
    at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:204)
    at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:148)
    ... 51 more
Caused by: javax.wsdl.WSDLException: WSDLException (at /definitions/types/xsd:schema): faultCode=PARSER_ERROR: Problem parsing 'http://dubdubdub.com/licenseService?xsd=1'.: org.xml.sax.SAXParseException: The element type "hr" must be terminated by the matching end-tag "</hr>".
    at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.parseTypes(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
    at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:242)
    at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:191)
    at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:92)
    ... 53 more
Caused by: org.xml.sax.SAXParseExceptionpublicId: http://dubdubdub.com/licenseService?xsd=1; systemId: http://dubdubdub.com/licenseService?xsd=1; lineNumber: 6; columnNumber: 3; The element type "hr" must be terminated by the matching end-tag "</hr>".
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    ... 63 more

1 个答案:

答案 0 :(得分:1)

我猜,当从“真实”服务客户端调用时,stacktrace http://dubdubdub.com/licenseService?xsd=1中给出的URL会返回错误消息。

也许您应该检查给定的网址是否确实有效。 WSDL解析器抱怨未关闭的<hr>标记,这表明Web服务客户端正在获取错误页面而不是可解析的模式文件。