Jpa 将WS-payload保存到Camel中的数据库中

Jpa 将WS-payload保存到Camel中的数据库中,jpa,jax-ws,cxf,apache-camel,Jpa,Jax Ws,Cxf,Apache Camel,我绝对是阿帕奇骆驼队的新手。我想创建一个非常简单的应用程序,它将接受WS-calls并使用JPA将负载保存到数据库中。 有效载荷的结构非常简单。根是婚姻对象。它包含一些字符串、int和日期字段、妻子、丈夫和子女列表(Person对象) 我的目标是将这些数据保存到数据库的两个表中:婚姻,人 我已经成功创建了一个jaxws:endpoint,在其中我侦听并响应一个虚拟响应。 我已经创建了表和JPA实体 我不知道如何将WS实现与spring配置的JpaTemplate“连接”。我应该通过使用@Conv

我绝对是阿帕奇骆驼队的新手。我想创建一个非常简单的应用程序,它将接受WS-calls并使用JPA将负载保存到数据库中。 有效载荷的结构非常简单。根是婚姻对象。它包含一些字符串、int和日期字段、妻子、丈夫和子女列表(Person对象)

我的目标是将这些数据保存到数据库的两个表中:婚姻,人

我已经成功创建了一个jaxws:endpoint,在其中我侦听并响应一个虚拟响应。 我已经创建了表和JPA实体

我不知道如何将WS实现与spring配置的JpaTemplate“连接”。我应该通过使用@Converter类或@Injet将其通过Spring导入WS实现类来解决驼峰路由问题吗。我很困惑


我应该使用cxf端点而不是jaxws端点吗?

如果要使用camel,需要使用
camle cxf
端点。我要做的是将端点公开为
camlecxf
端点。大概是这样的:

<camel-cxf:cxfEndpoint id="listenerEndpoint"
                       address="http://0.0.0.0:8022/Dummy/services/Dummy"
                       wsdlURL="wsdl/DummyService.wsdl"
                       xmlns:tns="http://dummy.com/ws/Dummy"
                       serviceName="tns:Dummy"
                       endpointName="tns:DummyService">
    <camel-cxf:properties>
        <entry key="schema-validation-enabled" value="true"/>
        <entry key="dataFormat" value="PAYLOAD"/>
    </camel-cxf:properties>
</camel-cxf:cxfEndpoint>
<bean id="processor" class="com.dummy.DummyProcessor">
     <property name="..." value="..."/> //there goes your data source of jdbc template or whatever...
</bean>
public class DummyProcessor {

    @Trancational //If you need transaction to be at this level...
    public void processRequest(Exchange exchange) {
        YourPayloadObject object = exchange.getIn().getBody(YourPayloadObject.class);
        //object - is your object from SOAP request, now you can get all the data and store it in the database.
    }
}
<camel:camelContext trace="true" id="camelContext" >

    <camel:route id="listenerEndpointRoute">
        <camel:from uri="cxf:bean:listenerEndpoint?dataFormat=POJO&amp;synchronous=true" />
        <camel:log message="Got message. The expected operation is :: ${headers.operationName}"/>
        <camel:choice>
            <camel:when>
                <camel:simple>${headers.operationName} == 'YourPayloadObject'</camel:simple>
                <camel:bean ref="processor" method="processRequest"/>
            </camel:when>
        </camel:choice>
        <camel:log message="Got message before sending to target: ${headers.operationName}"/>
        <camel:to uri="cxf:bean:someTargetEndpointOrSomethingElse"/>
        <camel:log message="Got message received from target ${headers.operationName}"/>
    </camel:route>

</camel:camelContext>
骆驼路线如下:

<camel-cxf:cxfEndpoint id="listenerEndpoint"
                       address="http://0.0.0.0:8022/Dummy/services/Dummy"
                       wsdlURL="wsdl/DummyService.wsdl"
                       xmlns:tns="http://dummy.com/ws/Dummy"
                       serviceName="tns:Dummy"
                       endpointName="tns:DummyService">
    <camel-cxf:properties>
        <entry key="schema-validation-enabled" value="true"/>
        <entry key="dataFormat" value="PAYLOAD"/>
    </camel-cxf:properties>
</camel-cxf:cxfEndpoint>
<bean id="processor" class="com.dummy.DummyProcessor">
     <property name="..." value="..."/> //there goes your data source of jdbc template or whatever...
</bean>
public class DummyProcessor {

    @Trancational //If you need transaction to be at this level...
    public void processRequest(Exchange exchange) {
        YourPayloadObject object = exchange.getIn().getBody(YourPayloadObject.class);
        //object - is your object from SOAP request, now you can get all the data and store it in the database.
    }
}
<camel:camelContext trace="true" id="camelContext" >

    <camel:route id="listenerEndpointRoute">
        <camel:from uri="cxf:bean:listenerEndpoint?dataFormat=POJO&amp;synchronous=true" />
        <camel:log message="Got message. The expected operation is :: ${headers.operationName}"/>
        <camel:choice>
            <camel:when>
                <camel:simple>${headers.operationName} == 'YourPayloadObject'</camel:simple>
                <camel:bean ref="processor" method="processRequest"/>
            </camel:when>
        </camel:choice>
        <camel:log message="Got message before sending to target: ${headers.operationName}"/>
        <camel:to uri="cxf:bean:someTargetEndpointOrSomethingElse"/>
        <camel:log message="Got message received from target ${headers.operationName}"/>
    </camel:route>

</camel:camelContext>

${headers.operationName}=='YourPayloadObject'

希望这有帮助。

你好,保利乌斯!谢谢你的帮助!使用您的示例代码,我可以做我想做的事情。现在我可以开始了。我的下一个目标是将我的试点应用程序与jBPM集成。哦,我接受了你的建议,用CXF替换JAXWS。