WSDL 在 JAX-WS Web 服务中不可用
WSDL not available in JAX-WS Web Service
我正在使用 Eclipse Mars 和 Apache CXF 3.06 来创建一个 JAX-WS 兼容的 Web 服务,我的 Java 版本是 JDK 1.7.0_45。我正在关注 this tutorial,但我无法完成,因为我看不到 WSDL 导航器(步骤 18)
下图是目前我正在做的过程:
1- 我的 Apache CXF 2.x 首选项设置为下一个屏幕截图:
2- 然后我用这些项目构面创建了一个动态 Web 项目
3- 动态 Web 项目最终 CONF
4- 我创建了一个名为 Calculate 的 class,其中包含下一个代码:
package test;
public class Calculate {
public Integer calculateSum(int i, int j) {
return i + j;
}
public Integer multiplyNumber(int i, int j) {
return i * j;
}
public Integer divideNumber(int i, int j) {
return i / j;
}
}
5- 然后右键单击 class 并转到 Web 服务,这是我的最终配置:
6- 我已经完全按照教程指示和其他步骤创建了界面,但是当我启动 Web Services Explorer 时,我无法看到 WSDL Main。
甚至当我尝试启动 WSDL URL 浏览器时,它一直说,请稍等,表格正在加载...永远
在 WebContent 内 --> wsdl 有 calculate.wsdl 文件和下一个代码:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="CalculateService" targetNamespace="http://test/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://test/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://test/" schemaLocation="calculate_schema1.xsd"/>
</schema>
</wsdl:types>
<wsdl:message name="divideNumberResponse">
<wsdl:part name="parameters" element="tns:divideNumberResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="calculateSum">
<wsdl:part name="parameters" element="tns:calculateSum">
</wsdl:part>
</wsdl:message>
<wsdl:message name="multiplyNumberResponse">
<wsdl:part name="parameters" element="tns:multiplyNumberResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="multiplyNumber">
<wsdl:part name="parameters" element="tns:multiplyNumber">
</wsdl:part>
</wsdl:message>
<wsdl:message name="calculateSumResponse">
<wsdl:part name="parameters" element="tns:calculateSumResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="divideNumber">
<wsdl:part name="parameters" element="tns:divideNumber">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="CalculateInterface">
<wsdl:operation name="divideNumber">
<wsdl:input name="divideNumber" message="tns:divideNumber">
</wsdl:input>
<wsdl:output name="divideNumberResponse" message="tns:divideNumberResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="multiplyNumber">
<wsdl:input name="multiplyNumber" message="tns:multiplyNumber">
</wsdl:input>
<wsdl:output name="multiplyNumberResponse" message="tns:multiplyNumberResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="calculateSum">
<wsdl:input name="calculateSum" message="tns:calculateSum">
</wsdl:input>
<wsdl:output name="calculateSumResponse" message="tns:calculateSumResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CalculateServiceSoapBinding" type="tns:CalculateInterface">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="divideNumber">
<soap:operation soapAction="urn:DivideNumber" style="document"/>
<wsdl:input name="divideNumber">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="divideNumberResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="calculateSum">
<soap:operation soapAction="urn:CalculateSum" style="document"/>
<wsdl:input name="calculateSum">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="calculateSumResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="multiplyNumber">
<soap:operation soapAction="urn:MultiplyNumber" style="document"/>
<wsdl:input name="multiplyNumber">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="multiplyNumberResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CalculateService">
<wsdl:port name="CalculatePort" binding="tns:CalculateServiceSoapBinding">
<soap:address location="http://localhost:8080/WebService/services/CalculatePort"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
我认为 tomcat 初始化时有问题,当我去控制台查看日志 Tomcat 放在那里时,有一些讨厌的异常,这里是 Tomcat的日志:
WARNING: Exception configuring digester to permit java encoding names in XML files. Only IANA encoding names will be supported.
org.xml.sax.SAXNotRecognizedException: http://apache.org/xml/features/allow-java-encodings
at oracle.xml.jaxp.JXSAXParserFactory.setFeature(JXSAXParserFactory.java:128)
at org.apache.tomcat.util.digester.Digester.setFeature(Digester.java:538)
at org.apache.catalina.users.MemoryUserDatabase.open(MemoryUserDatabase.java:411)
at org.apache.catalina.users.MemoryUserDatabaseFactory.getObjectInstance(MemoryUserDatabaseFactory.java:104)
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
at org.apache.naming.NamingContextBindingsEnumeration.nextElementInternal(NamingContextBindingsEnumeration.java:119)
at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:73)
at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:36)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:140)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:112)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.lifecycleEvent(GlobalResourcesLifecycleListener.java:84)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:347)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:725)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.startup.Catalina.start(Catalina.java:691)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:456)
Aug 26, 2015 8:17:50 AM org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 in XML document from ServletContext resource [/WEB-INF/cxf-beans.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 200; <Line 4, Column 200>: XML-24500: (Error) Can not build schema 'http://cxf.apache.org/jaxws' located at 'http://cxf.apache.org/schemas/jaxws.xsd'
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 200; <Line 4, Column 200>: XML-24500: (Error) Can not build schema 'http://cxf.apache.org/jaxws' located at 'http://cxf.apache.org/schemas/jaxws.xsd'
at oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:418)
at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:284)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:300)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:200)
at oracle.xml.jaxp.JXDocumentBuilder.parse(JXDocumentBuilder.java:155)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
... 22 more
Caused by: oracle.xml.parser.schema.XSDException: Duplicated definition for: 'identifiedType'
at oracle.xml.parser.schema.XSDBuilder.buildSchema(XSDBuilder.java:748)
at oracle.xml.parser.schema.XSDBuilder.build(XSDBuilder.java:448)
at oracle.xml.parser.schema.XSDValidator.processSchemaLocation(XSDValidator.java:972)
at oracle.xml.parser.schema.XSDValidator.startElement(XSDValidator.java:581)
at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1276)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:324)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:291)
... 26 more
Aug 26, 2015 8:17:50 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 in XML document from ServletContext resource [/WEB-INF/cxf-beans.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 200; <Line 4, Column 200>: XML-24500: (Error) Can not build schema 'http://cxf.apache.org/jaxws' located at 'http://cxf.apache.org/schemas/jaxws.xsd'
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 200; <Line 4, Column 200>: XML-24500: (Error) Can not build schema 'http://cxf.apache.org/jaxws' located at 'http://cxf.apache.org/schemas/jaxws.xsd'
at oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:418)
at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:284)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:300)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:200)
at oracle.xml.jaxp.JXDocumentBuilder.parse(JXDocumentBuilder.java:155)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
... 22 more
Caused by: oracle.xml.parser.schema.XSDException: Duplicated definition for: 'identifiedType'
at oracle.xml.parser.schema.XSDBuilder.buildSchema(XSDBuilder.java:748)
at oracle.xml.parser.schema.XSDBuilder.build(XSDBuilder.java:448)
at oracle.xml.parser.schema.XSDValidator.processSchemaLocation(XSDValidator.java:972)
at oracle.xml.parser.schema.XSDValidator.startElement(XSDValidator.java:581)
at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1276)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:324)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:291)
... 26 more
WARNING: Exception thrown from ApplicationListener handling ContextClosedEvent
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Wed Aug 26 08:17:50 EDT 2015]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:347)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1049)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:559)
at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4980)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5626)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Aug 26, 2015 8:17:50 AM org.springframework.context.support.AbstractApplicationContext doClose
WARNING: Exception thrown from LifecycleProcessor on context close
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Wed Aug 26 08:17:50 EDT 2015]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:360)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1057)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:559)
at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4980)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5626)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Aug 26, 2015 8:17:50 AM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:171)
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1090)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1064)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:559)
at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4980)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5626)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Web 服务的问题是在初始化时 Tomcat。我正在阅读 posts related 到 tomcat 的错误输出并尝试包含 cxf-rt-bindings-soap.jar
即使此文件已包含在 CXF 库中,这种方法也不起作用。
真正有效的解决方案是从 WebContent/WEB-INF/cxf-beans.xml
中删除 import resource="classpath:META-INF/ cxf/ cxf-extension-soap.xml" />
,this link 强制执行此解决方案。
我想知道为什么 cxf-beans.xml
仍然使用此 class 路径生成,即使不再需要它,即使 Apache CXF 的版本相对较新(CXF 3.06 - - 2015 年 8 月 3 日)
我正在使用 Eclipse Mars 和 Apache CXF 3.06 来创建一个 JAX-WS 兼容的 Web 服务,我的 Java 版本是 JDK 1.7.0_45。我正在关注 this tutorial,但我无法完成,因为我看不到 WSDL 导航器(步骤 18)
下图是目前我正在做的过程:
1- 我的 Apache CXF 2.x 首选项设置为下一个屏幕截图:
2- 然后我用这些项目构面创建了一个动态 Web 项目
3- 动态 Web 项目最终 CONF
4- 我创建了一个名为 Calculate 的 class,其中包含下一个代码:
package test;
public class Calculate {
public Integer calculateSum(int i, int j) {
return i + j;
}
public Integer multiplyNumber(int i, int j) {
return i * j;
}
public Integer divideNumber(int i, int j) {
return i / j;
}
}
5- 然后右键单击 class 并转到 Web 服务,这是我的最终配置:
6- 我已经完全按照教程指示和其他步骤创建了界面,但是当我启动 Web Services Explorer 时,我无法看到 WSDL Main。
甚至当我尝试启动 WSDL URL 浏览器时,它一直说,请稍等,表格正在加载...永远
在 WebContent 内 --> wsdl 有 calculate.wsdl 文件和下一个代码:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="CalculateService" targetNamespace="http://test/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://test/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://test/" schemaLocation="calculate_schema1.xsd"/>
</schema>
</wsdl:types>
<wsdl:message name="divideNumberResponse">
<wsdl:part name="parameters" element="tns:divideNumberResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="calculateSum">
<wsdl:part name="parameters" element="tns:calculateSum">
</wsdl:part>
</wsdl:message>
<wsdl:message name="multiplyNumberResponse">
<wsdl:part name="parameters" element="tns:multiplyNumberResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="multiplyNumber">
<wsdl:part name="parameters" element="tns:multiplyNumber">
</wsdl:part>
</wsdl:message>
<wsdl:message name="calculateSumResponse">
<wsdl:part name="parameters" element="tns:calculateSumResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="divideNumber">
<wsdl:part name="parameters" element="tns:divideNumber">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="CalculateInterface">
<wsdl:operation name="divideNumber">
<wsdl:input name="divideNumber" message="tns:divideNumber">
</wsdl:input>
<wsdl:output name="divideNumberResponse" message="tns:divideNumberResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="multiplyNumber">
<wsdl:input name="multiplyNumber" message="tns:multiplyNumber">
</wsdl:input>
<wsdl:output name="multiplyNumberResponse" message="tns:multiplyNumberResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="calculateSum">
<wsdl:input name="calculateSum" message="tns:calculateSum">
</wsdl:input>
<wsdl:output name="calculateSumResponse" message="tns:calculateSumResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CalculateServiceSoapBinding" type="tns:CalculateInterface">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="divideNumber">
<soap:operation soapAction="urn:DivideNumber" style="document"/>
<wsdl:input name="divideNumber">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="divideNumberResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="calculateSum">
<soap:operation soapAction="urn:CalculateSum" style="document"/>
<wsdl:input name="calculateSum">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="calculateSumResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="multiplyNumber">
<soap:operation soapAction="urn:MultiplyNumber" style="document"/>
<wsdl:input name="multiplyNumber">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="multiplyNumberResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CalculateService">
<wsdl:port name="CalculatePort" binding="tns:CalculateServiceSoapBinding">
<soap:address location="http://localhost:8080/WebService/services/CalculatePort"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
我认为 tomcat 初始化时有问题,当我去控制台查看日志 Tomcat 放在那里时,有一些讨厌的异常,这里是 Tomcat的日志:
WARNING: Exception configuring digester to permit java encoding names in XML files. Only IANA encoding names will be supported.
org.xml.sax.SAXNotRecognizedException: http://apache.org/xml/features/allow-java-encodings
at oracle.xml.jaxp.JXSAXParserFactory.setFeature(JXSAXParserFactory.java:128)
at org.apache.tomcat.util.digester.Digester.setFeature(Digester.java:538)
at org.apache.catalina.users.MemoryUserDatabase.open(MemoryUserDatabase.java:411)
at org.apache.catalina.users.MemoryUserDatabaseFactory.getObjectInstance(MemoryUserDatabaseFactory.java:104)
at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at org.apache.naming.NamingContext.lookup(NamingContext.java:843)
at org.apache.naming.NamingContext.lookup(NamingContext.java:154)
at org.apache.naming.NamingContextBindingsEnumeration.nextElementInternal(NamingContextBindingsEnumeration.java:119)
at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:73)
at org.apache.naming.NamingContextBindingsEnumeration.next(NamingContextBindingsEnumeration.java:36)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:140)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.createMBeans(GlobalResourcesLifecycleListener.java:112)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.lifecycleEvent(GlobalResourcesLifecycleListener.java:84)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:347)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:725)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.startup.Catalina.start(Catalina.java:691)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:456)
Aug 26, 2015 8:17:50 AM org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 in XML document from ServletContext resource [/WEB-INF/cxf-beans.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 200; <Line 4, Column 200>: XML-24500: (Error) Can not build schema 'http://cxf.apache.org/jaxws' located at 'http://cxf.apache.org/schemas/jaxws.xsd'
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 200; <Line 4, Column 200>: XML-24500: (Error) Can not build schema 'http://cxf.apache.org/jaxws' located at 'http://cxf.apache.org/schemas/jaxws.xsd'
at oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:418)
at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:284)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:300)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:200)
at oracle.xml.jaxp.JXDocumentBuilder.parse(JXDocumentBuilder.java:155)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
... 22 more
Caused by: oracle.xml.parser.schema.XSDException: Duplicated definition for: 'identifiedType'
at oracle.xml.parser.schema.XSDBuilder.buildSchema(XSDBuilder.java:748)
at oracle.xml.parser.schema.XSDBuilder.build(XSDBuilder.java:448)
at oracle.xml.parser.schema.XSDValidator.processSchemaLocation(XSDValidator.java:972)
at oracle.xml.parser.schema.XSDValidator.startElement(XSDValidator.java:581)
at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1276)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:324)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:291)
... 26 more
Aug 26, 2015 8:17:50 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 4 in XML document from ServletContext resource [/WEB-INF/cxf-beans.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 200; <Line 4, Column 200>: XML-24500: (Error) Can not build schema 'http://cxf.apache.org/jaxws' located at 'http://cxf.apache.org/schemas/jaxws.xsd'
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 200; <Line 4, Column 200>: XML-24500: (Error) Can not build schema 'http://cxf.apache.org/jaxws' located at 'http://cxf.apache.org/schemas/jaxws.xsd'
at oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:418)
at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:284)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:300)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:200)
at oracle.xml.jaxp.JXDocumentBuilder.parse(JXDocumentBuilder.java:155)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
... 22 more
Caused by: oracle.xml.parser.schema.XSDException: Duplicated definition for: 'identifiedType'
at oracle.xml.parser.schema.XSDBuilder.buildSchema(XSDBuilder.java:748)
at oracle.xml.parser.schema.XSDBuilder.build(XSDBuilder.java:448)
at oracle.xml.parser.schema.XSDValidator.processSchemaLocation(XSDValidator.java:972)
at oracle.xml.parser.schema.XSDValidator.startElement(XSDValidator.java:581)
at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1276)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:324)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:291)
... 26 more
WARNING: Exception thrown from ApplicationListener handling ContextClosedEvent
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Wed Aug 26 08:17:50 EDT 2015]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:347)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1049)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:559)
at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4980)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5626)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Aug 26, 2015 8:17:50 AM org.springframework.context.support.AbstractApplicationContext doClose
WARNING: Exception thrown from LifecycleProcessor on context close
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Wed Aug 26 08:17:50 EDT 2015]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:360)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1057)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:559)
at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4980)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5626)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Aug 26, 2015 8:17:50 AM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:171)
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1090)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1064)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:559)
at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4980)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5626)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Web 服务的问题是在初始化时 Tomcat。我正在阅读 posts related 到 tomcat 的错误输出并尝试包含 cxf-rt-bindings-soap.jar
即使此文件已包含在 CXF 库中,这种方法也不起作用。
真正有效的解决方案是从 WebContent/WEB-INF/cxf-beans.xml
中删除 import resource="classpath:META-INF/ cxf/ cxf-extension-soap.xml" />
,this link 强制执行此解决方案。
我想知道为什么 cxf-beans.xml
仍然使用此 class 路径生成,即使不再需要它,即使 Apache CXF 的版本相对较新(CXF 3.06 - - 2015 年 8 月 3 日)