使用ActiveMQ的SOAP Web服务产生奇怪的响应

时间:2014-08-22 20:07:25

标签: mule mule-studio

我有一个暴露SOAP Web服务的Mule Flow: -

<jms:activemq-connector name="Active_MQ" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>

<flow name="Flow1" doc:name="Flow1" >
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" doc:name="HTTP"/>
<cxf:jaxws-service serviceClass="com.test.services.schema.maindata.v1.MainData"  doc:name="SOAP"/>
<mulexml:object-to-xml-transformer doc:name="Object to XML"/>
<jms:outbound-endpoint queue="NewQueue" connector-ref="Active_MQ" doc:name="JMS" exchange-pattern="request-response"/>
<logger message="Response2 :- #[message.payload]" level="INFO" doc:name="Logger"/>
<mulexml:xml-to-object-transformer doc:name="XML to Object"/>
</flow>


<flow name="flow2" doc:name="flow2" >
<jms:inbound-endpoint connector-ref="Active_MQ" address="jms://tcp:NewQueue" doc:name="JMS" exchange-pattern="request-response" disableTemporaryReplyToDestinations="true" responseTimeout="90000"/>
<set-variable variableName="SOAPRequest" value="#[message.payload]" doc:name="Variable"/>
<mulexml:xml-to-object-transformer doc:name="XML to Object"/>
<component class="com.test.services.schema.maindata.v1.Impl.MainDataImpl" doc:name="JavaMain_ServiceImpl">
<method-entry-point-resolver>
        <include-entry-point method="retrieveDataOperation"/>
        <include-entry-point method="insertDataOperation"/>
        <include-entry-point method="updateDataOperation"/>
        <include-entry-point method="deleteDataOperation"/>
</method-entry-point-resolver>
</component>
<mulexml:object-to-xml-transformer doc:name="Object to XML"/>
 </flow>

现在Web服务中有4个方法: - MainDataImpl类中的retrieveDataOperation(),insertDataOperation(),updateDataOperation()和deleteDataOperation()。所有方法都有不同的Response消息......但奇怪的是如果我在SOAP UI中测试应用程序,我会发现操作insertDataOperation()和updateDataOperation()给出相同的响应,尽管MainDataImpl类中的响应都不同。 我不知道为什么updateDataOperation()方法显示了insertDataOperation()的响应..

我怀疑在目前的流程中我使用了以下内容: -

<component class="com.test.services.schema.maindata.v1.Impl.MainDataImpl" doc:name="JavaMain_ServiceImpl">
<method-entry-point-resolver>
        <include-entry-point method="retrieveDataOperation"/>
        <include-entry-point method="insertDataOperation"/>
        <include-entry-point method="updateDataOperation"/>
        <include-entry-point method="deleteDataOperation"/>
</method-entry-point-resolver>
</component>

我的xsd文件如下: -

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://services.test.com/schema/MainData/V1" xmlns:tns="http://services.test.com/schema/MainData/V1" elementFormDefault="qualified">


    <complexType name="dataRequest">
        <sequence>
            <element name="Id" type="int"></element>
            <element name="Name" type="string"></element>
            <element name="Age" type="int"></element>
            <element name="Designation" type="string"></element>
        </sequence>
    </complexType>

    <complexType name="dataResponse">
        <sequence>
            <element name="Response" type="string"></element>
            <element name="Id" type="int"></element>
            <element name="Name" type="string"></element>
            <element name="Age" type="int"></element>
            <element name="Designation" type="string"></element>
        </sequence>
    </complexType>

    <element name="insertDataRequest" type="tns:dataRequest"></element>

    <element name="insertDataResponse" type="tns:dataResponse"></element>


    <element name="retrieveDataRequest" type="tns:retrieveRequest"></element>

    <element name="retrieveDataResponse" type="tns:dataResponse"></element>

    <complexType name="retrieveRequest">
        <sequence>
            <element name="Id" type="int"></element>
        </sequence>
    </complexType>

    <element name="updateDataRequest" type="tns:dataRequest"></element>

    <element name="updateDataRespone" type="tns:dataResponse"></element>

    <complexType name="deleteRequest">
        <sequence>
            <element name="ID" type="int"></element>
        </sequence>
    </complexType>

    <element name="deleteDataRequest" type="tns:deleteRequest"></element>

    <element name="deleteDataResponse" type="tns:dataResponse"></element>
</schema>

我是否需要在JMS出站端点之前添加一些内容,以便它可以区分这两种方法..请帮助..

2 个答案:

答案 0 :(得分:1)

我认为method-entry-point-resolver根本没用:Mule可以自动找到这4种方法。

主要问题来自于insertDataOperationupdateDataOperation都收到相同类型的对象(DataRequest); retrieveDataRequest收到RetrieveRequestdeleteDataOperation收到DeleteRequest

您可以更改WSDL,以便insertDataOperationupdateDataOperation接收特定类型吗?

如果没有,那么您将必须根据CXF创建的流变量(method,{{}从流1到流2携带要在组件上调用的实际方法的名称。 1}}和cxf_operation)。

您可能还希望使用cxf_service消息处理器而不是invoke来更轻松地控制调用的方法。

答案 1 :(得分:0)

因此,根据David的建议,工作解决方案是在属性

中设置methodname
 <set-property propertyName="methodName" value="#[cxf_operation.localPart]" doc:name="methodNameProperty"/>

然后在Java实现类中调用它: -

<component class="com.test.services.schema.maindata.v1.Impl.MainDataImpl" doc:name="Java">
    <property-entry-point-resolver property="methodName"/> 
 </component>