我使用maven cxf-codegen-plugin
从wsdl生成了一个web服务。这很好,我没有例外。
然后我尝试使用此代码实例化Web服务(生成Service类):
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setEndpointName(SERVICE_NAME);
factory.setAddress("https://someadress:port/spec");
factory.setServiceClass(Service.class);
this.port = (Service) factory.create();
在调用create方法时,我在weblogic上运行时收到以下异常:
weblogic.application.ModuleException: org.apache.ws.commons.schema.XmlSchemaException: Top-level attributes may not have a 'use'
...
Caused By: org.apache.ws.commons.schema.XmlSchemaException: Top-level attributes may not have a 'use'
at org.apache.ws.commons.schema.XmlSchemaAttribute.setUse(XmlSchemaAttribute.java:109)
at org.apache.ws.commons.schema.SchemaBuilder.handleAttribute(SchemaBuilder.java:966)
at org.apache.ws.commons.schema.SchemaBuilder.handleSchemaElementChild(SchemaBuilder.java:1519)
at org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:659)
at org.apache.ws.commons.schema.SchemaBuilder.build(SchemaBuilder.java:157)
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:497)
at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:483)
at org.apache.cxf.common.xmlschema.SchemaCollection.read(SchemaCollection.java:133)
at org.apache.cxf.databinding.AbstractDataBinding.addSchemaDocument(AbstractDataBinding.java:192)
at org.apache.cxf.databinding.AbstractDataBinding.addSchemaDocument(AbstractDataBinding.java:95)
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:393)
at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:490)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:697)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:550)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:265)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:214)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:90)
at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:155)
at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:156)
AFIAK,在webservice的初始化中没有引用wsdl,我认为当成功生成类时,Web服务是从有效源生成的。
无论如何,我不知道该消息是什么意思。是的,我在互联网上找到了关于这个问题的这个单一链接:http://cxf.547215.n5.nabble.com/Schema-validation-errors-on-publish-quot-top-level-elements-may-not-have-a-use-quot-td5724860.html 但我仍然不知道出了什么问题。
另一件事是,我不太确定顶级属性的定义是什么。我用谷歌搜索“xml顶级属性”,但在前两页的结果中,没有定义。
所以我搜索了wsdl引用的XSD,并在opengis gml中发现了一些包含“use =”的东西,还有一个XSD:
<complexType name="UnitOfMeasureType">
<sequence/>
<attribute name="uom" type="gml:UomIdentifier" use="required"/>
</complexType>
还有这个:
<attributeGroup name="extendedLink">
<attribute name="type" type="string" fixed="extended" form="qualified"/>
<attribute ref="xlink:role" use="optional"/>
<attribute ref="xlink:title" use="optional"/>
</attributeGroup>
这些事情中有一些是个问题吗?
当我从单元测试中运行web服务时,webservice可以正常工作,但在Weblogic上部署时则不行。
我用:
答案 0 :(得分:1)
最新版本的Weblogic使用MOXy作为JAXB实现而不是JAXB 参考实现或JDK中内置的实现。如果这在Weblogic之外工作,那么它可能是MOXy中的一个问题。 CXF团队在MOXy的架构(以及其他领域)中发现了几个错误。好消息是,MOXy团队通常会非常迅速地解决任何问题。如果你可以将它提炼成一个小的测试用例,这可能是一个很大的帮助。