0
votes

I have a Mule Flow which is exposing a SOAP web service :-

<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>

Now there are 4 methods in the web service :- retrieveDataOperation(), insertDataOperation() ,updateDataOperation() and deleteDataOperation() in the MainDataImpl class.. All the methods have different Response messages ... But the strange thing is that if I test the application in SOAP UI I will find both the operation insertDataOperation() and updateDataOperation() gives the same response although the response are different for both in MainDataImpl class .. I don't know why the updateDataOperation() method is showing the response of insertDataOperation() ..

I suspect in the present flow I have used the following :-

<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>

My xsd file is as follows :-

<?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>

Do I need to add something before JMS outbound endpoint so that it can differentiate both the methods .. Please help ..

2

2 Answers

1
votes

I don't think the method-entry-point-resolver is useful at all: Mule can locate these 4 methods automatically.

The main issue comes from the fact that both insertDataOperation and updateDataOperation receive an object of the same type (DataRequest); while retrieveDataRequest receives a RetrieveRequest and deleteDataOperation receives a DeleteRequest.

Can you change the WSDL so insertDataOperation and updateDataOperation receive specific types?

If not, then you will have to carry along, from flow 1 to flow 2, the name of the actual method to invoke on the component, based on the flow variables that CXF creates (method, cxf_operation and cxf_service).

You may also want to use the invoke message processor instead of component to have easier control of what method is invoked.

0
votes

So, as per David's suggestion, the working solution is setting methodname in property

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

and then invoking it in Java implementation class :-

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