Search code examples
javaxmljaxbwsdlcxf

SAXParseException in JAXB during CXF WebService test


I am new to JAXB. I was provided a wsdl file, I used apache-cxf utility wsdl2java to gain a number of java classes, from which I implemented my webservice. But when I start client server test on my service, I get the following exception:

мар 25, 2013 12:19:36 PM org.apache.cxf.wsdl.EndpointReferenceUtils createSchema
WARNING: SAXException for newSchema()
org.xml.sax.SAXParseException; src-import.1.1: The namespace attribute 'http://www.aaa.com/bbb/ccc/ddd' of an <import> element information item must not be the same as the targetNamespace of the schema it exists in.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaError(Unknown Source)
    at org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source)
    at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
    at org.apache.xerces.jaxp.validation.XMLSchemaFactory.newSchema(Unknown Source)
    at org.apache.cxf.wsdl.EndpointReferenceUtils.createSchema(EndpointReferenceUtils.java:698)
    at org.apache.cxf.wsdl.EndpointReferenceUtils.getSchema(EndpointReferenceUtils.java:743)
    at org.apache.cxf.binding.soap.interceptor.SoapHeaderInterceptor.handleMessage(SoapHeaderInterceptor.java:107)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
    at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:800)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1590)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1488)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1307)
    at org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:50)
    at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:229)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:622)
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:133)

.............
INFO: Schema for: http://www.globe.com/warcraft/wsdl/amax
<?xml version="1.0" encoding="utf-8"?><xs:schema xmlns:tns="http://www.aaa.com/bbb/ccc/ddd" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.aaa.com/bbb/ccc/ddd" version="1.0">
<xs:import namespace="http://www.aaa.com/bbb/ccc/ddd"/>
...........

Why this intermediate XML is generated so, that it is importing itself? Can appearance of this import tag be cancelled somehow? I suppose, that the reason may be in the initial wsdl, or maybe it is some bug.

Thanks in advance


Solution

  • The problem was because in my generated ProxyServiceImpl class, I was missing a wsdlLocation in @WebService annotation:

    @javax.jws.WebService(
                      serviceName = "ServiceName",
                      portName = "ServicePort",
                      targetNamespace = "http://www.aaa.com/bbb/ccc/ddd",
                      wsdlLocation = "path_to_wsdl",
                      endpointInterface = "ProxyService_class")
    

    When I added it, everything worked.