restful 服务请求的配置 application/xml 媒体类型 spring 集成网络服务

Configuration for restful service request for application/xml media type for spring integration webservice

虽然使用 spring 集成来满足具有 application/xml 媒体类型的 restful 请求,但是在部署 Web 应用程序时出现以下异常:

Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: org.springframework.beans.NotWritablePropertyException: Invalid property 'componentName' of bean class [org.springframework.oxm.jaxb.Jaxb2Marshaller]: Bean property 'componentName' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?. Please see server.log for more details.   

以下是满足媒体类型 application/xml:

的 Web 请求的示例配置
<int:channel id="xmlServiceImplChannel" />
<int:channel id="xmlServiceReqImplChannel" />

<int-http:inbound-gateway request-channel="xmlServiceImplChannel"
    supported-methods="POST" path="/xmlServiceImplReq"/>


<!-- this is require to enrich the header to handle the content-type of 
    type "application/xml" -->
<int:header-enricher input-channel="xmlServiceImplChannel"
    output-channel="xmlServiceReqImplChannel">
    <int:header name="content-type" value="application/xml"></int:header>
</int:header-enricher>

<int:chain input-channel="xmlServiceReqImplChannel">


<oxm:jaxb2-marshaller id="xmlMarshaller" context-path="com.xyz.channel.model"></oxm:jaxb2-marshaller>

<int:service-activator>
    <bean class="com.xyz.channel.model.serviceImpl.xmlServiceImpl"><constructor-arg ref="xmlServiceType"></constructor-arg></bean>
</int:service-activator>

<oxm:jaxb2-marshaller id="xmlMarshaller" context-path="com.xyz.channel.model"></oxm:jaxb2-marshaller>

</int:chain>

如果我缺少某些配置,请告诉我。

您的问题是您尝试在 <chain> 中使用 <oxm:jaxb2-marshaller>,但无法完成,因为只有 MessageHandler 实现可以用作 <bean>那里。

为了您的目的,您应该使用 <int-xml:marshalling-transformer> 并将顶层 xmlMarshaller 注入 <chain>:

中的那个组件
<oxm:jaxb2-marshaller id="xmlMarshaller" context-path="com.xyz.channel.model"></oxm:jaxb2-marshaller>

<int:chain input-channel="xmlServiceReqImplChannel">
   <si-xml:marshalling-transformer marshaller="xmlMarshaller" /> 
   <int:service-activator>
      <bean class="com.xyz.channel.model.serviceImpl.xmlServiceImpl"><constructor-arg     ref="xmlServiceType"></constructor-arg></bean>
   </int:service-activator>

</int:chain>

从另一方面来说,我不清楚在 <service-activator>...

之后使用第二个编组器的原因是什么