我已经自己寻找了一段时间来解决这个问题,但最终在这里提出了问题,因为到目前为止我找不到任何解决方案。我们有一个在apachecamel上开发的带有xmldsl定义的应用程序,它在旧版本的apachecamel中运行良好。我将它更新到了最新的3.19版本,在部署应用程序时出现了以下错误。
Caused by: org.xml.sax.SAXParseException; lineNumber: 35; columnNumber: 22; cvc-complex-type.3.2.2: Attribute 'uri' is not allowed to appear in element 'get'.
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://camel.apache.org/schema/spring
https://camel.apache.org/schema/spring/camel-spring-3.18.0.xsd
">
<camelContext
xmlns="http://camel.apache.org/schema/spring">
<rest path="/say">
<get uri="/hello">
<to uri="direct:hello" />
</get>
<get uri="/bye" consumes="application/json">
<to uri="direct:bye" />
</get>
<post uri="/bye">
<to uri="mock:update" />
</post>
</rest>
<route>
<from uri="direct:hello" />
<transform>
<constant>Hello World</constant>
</transform>
</route>
<route>
<from uri="direct:bye" />
<transform>
<constant>Bye World</constant>
</transform>
</route>
</camelContext>
</beans>
路线的定义如官方文件所示。任何帮助都将不胜感激。
自Camel 3.16.0版本以来,uri
属性已重命名为path
,请参阅此票证中的说明https://issues.apache.org/jira/browse/CAMEL-17673?focusedCommentId=17493997&page=com.atlassian.jira.plugin.system.sissuetabanels%3comment选项卡面板#comment-17493997
在3.16.0之前的驼色版本中
参见https://camel.apache.org/schema/spring/camel-spring-3.15.0.xsd
<xs:complexType name="verbDefinition">
<xs:complexContent>
<xs:extension base="tns:optionalIdentifiedDefinition">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="tns:param"/>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="tns:responseMessage"/>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="tns:security"/>
<xs:choice>
<xs:element ref="tns:to"/>
<xs:element ref="tns:toD"/>
<xs:element ref="tns:route"/>
</xs:choice>
</xs:sequence>
<xs:attribute name="method" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="en">
<![CDATA[ The HTTP verb such as GET, POST, DELETE, etc. ]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="uri" type="xs:string"> <!-- ***** HERE ****** -->
<xs:annotation>
<xs:documentation xml:lang="en">
<![CDATA[ Uri template of this REST service such as /{id}. ]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
自Camel v3.16.0起
参见https://camel.apache.org/schema/spring/camel-spring-3.16.0.xsd
<xs:complexType abstract="true" name="verbDefinition">
<xs:complexContent>
<xs:extension base="tns:optionalIdentifiedDefinition">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="tns:param"/>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="tns:responseMessage"/>
<xs:element maxOccurs="unbounded" minOccurs="0" ref="tns:security"/>
<xs:element ref="tns:to"/>
</xs:sequence>
<xs:attribute name="path" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="en">
<![CDATA[ The path mapping URIs of this REST operation such as /{id}. ]]>
</xs:documentation>
</xs:annotation>
</xs:attribute>
遗憾的是,Camel文档没有更新以反映这一变化,示例仍然使用uri
属性:https://camel.apache.org/manual/rest-dsl.html#_rest_dsl_with_xml_dsl