Search code examples
wso2rabbitmqwso2-data-services-serverwso2-esb

WSO2 ESB does not sent a clinicId param to WSO2 DSS


In WSO2 configured proxy service, does not send the clinicId param to DSS. In logs from DSS gives exception :

Default Namespace: https://bur.test.ru/dss/services/tfoms
Current Request Name: get_single_inserted_branch_by_id
Current Params: {clinicID=}
Nested Exception:-
java.lang.NumberFormatException: For input string: ""

In logs from ESB:


Nested Exception:-
javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'SQLQuery.processPreNormalQuery': For input string: ""
DS Code: DATABASE_ERROR
Source Data Service:-
Name: TEST
Location: \TEST.dbs
Description: Service generates hospitalisation&
Default Namespace: https://bur.TEST.ru/dss/services/tfoms Current Request Name: get_single_inserted_branch_by_id Current Params: {clinicID=} Nested Exception:- java.lang.NumberFormatException: For input string: ""
On WSO2 DSS it works good and it takes info from postgres. Here is a code of proxy servise from WSO2 ESB:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="BurProxy"
       transports="http,https"
       statistics="disable"
       trace="enable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="CLINIC_ID"
                   expression="//clinicID/text()"
                   scope="axis2"
                   type="STRING"/>
         <log level="full">
            <property name="CLINIC_ID" expression="clinicID"/>
         </log>
         <payloadFactory media-type="xml">
            <format>
               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                                 xmlns:tfom="https://bur.cdmarf.ru/dss/services/tfoms">
                  <soapenv:Header/>
                  <soapenv:Body>
                     <tfom:get_single_inserted_branch_by_id>
                        <tfom:clinicID>$1</tfom:clinicID>
                     </tfom:get_single_inserted_branch_by_id>
                  </soapenv:Body>
               </soapenv:Envelope>
            </format>
            <args>
               <arg evaluator="xml" expression="$axis2:CLINIC_ID"/>
            </args>
         </payloadFactory>
         <log>
            <property name="PAYLOAD" expression="$body"/>
         </log>
         <call blocking="true">
            <endpoint key="dss"/>
         </call>
         <xslt key="xslt-remove-namespace"/>
         <property name="messageType" value="text/xml" scope="axis2"/>
         <property name="contentType" value="text/xml" scope="axis2"/>
         <property name="rabbitmq.attributes.app.id"
                   value="RMIS"
                   scope="axis2"
                   type="STRING"/>
         <property name="rabbitmq.attributes.type"
                   value="BRANCH"
                   scope="axis2"
                   type="STRING"/>
         <property name="rabbitmq.attributes.user.id"
                   value="rmis"
                   scope="axis2"
                   type="STRING"/>
         <property name="MESSAGE_ID" expression="get-property('MessageID')"/>
         <script language="js">var messageID = mc.getProperty('MESSAGE_ID').substring(9,45);
         	mc.setProperty("RABBIT_MESSAGE_ID", messageID);</script>
         <property name="rabbitmq.attributes.custom.message.id"
                   expression="get-property('RABBIT_MESSAGE_ID')"
                   scope="axis2"/>
         <clone continueParent="true">
            <target sequence="writeToFile"/>
         </clone>
         <send>
            <endpoint key="rabbit"/>
         </send>
         <payloadFactory media-type="xml">
            <format>
               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                                 xmlns:tfom="https://bur.cdmarf.ru/dss/services/tfoms">
                  <soapenv:Header/>
                  <soapenv:Body>
                     <tfom:get_inserted_divisions_of_clinic>
                        <tfom:clinicID>$1</tfom:clinicID>
                     </tfom:get_inserted_divisions_of_clinic>
                  </soapenv:Body>
               </soapenv:Envelope>
            </format>
            <args>
               <arg evaluator="xml" expression="$axis2:CLINIC_ID"/>
            </args>
         </payloadFactory>
         <call blocking="true">
            <endpoint key="dss"/>
         </call>
         <iterate xmlns:tfoms="https://bur.cdmarf.ru/dss/services/tfoms"
                  continueParent="true"
                  expression="//tfoms:DIVISION"
                  sequential="true">
            <target>
               <sequence>
                  <property name="rabbitmq.attributes.type"
                            value="DIVISION"
                            scope="axis2"
                            type="STRING"/>
                  <property name="messageType" value="xml" scope="axis2"/>
                  <property name="contentType" value="xml" scope="axis2"/>
                  <property name="MESSAGE_ID" expression="get-property('MessageID')"/>
                  <script language="js">var messageID = mc.getProperty('MESSAGE_ID').substring(9,45);
         	       mc.setProperty("RABBIT_MESSAGE_ID", messageID);</script>
                  <property name="rabbitmq.attributes.custom.message.id"
                            expression="get-property('RABBIT_MESSAGE_ID')"
                            scope="axis2"/>
                  <xslt key="xslt-remove-namespace"/>
                  <clone continueParent="true">
                     <target sequence="writeToFile"/>
                  </clone>
                  <send>
                     <endpoint key="rabbit"/>
                  </send>
               </sequence>
            </target>
         </iterate>
         <payloadFactory media-type="xml">
            <format>
               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                                 xmlns:tfom="https://bur.cdmarf.ru/dss/services/tfoms">
                  <soapenv:Body>
                     <tfom:get_inserted_liks_division_to_bed>
                        <tfom:clinicID>$1</tfom:clinicID>
                     </tfom:get_inserted_liks_division_to_bed>
                  </soapenv:Body>
               </soapenv:Envelope>
            </format>
            <args>
               <arg evaluator="xml" expression="$axis2:CLINIC_ID"/>
            </args>
         </payloadFactory>
         <call blocking="true">
            <endpoint key="dss"/>
         </call>
         <iterate xmlns:tfoms="https://bur.cdmarf.ru/dss/services/tfoms"
                  continueParent="true"
                  expression="//tfoms:DIVISION_LINK_STRUCTURE_BED"
                  sequential="true">
            <target>
               <sequence>
                  <property name="rabbitmq.attributes.type"
                            value="DIVISION_LINK_STRUCTURE_BED"
                            scope="axis2"
                            type="STRING"/>
                  <property name="messageType" value="xml" scope="axis2"/>
                  <property name="contentType" value="xml" scope="axis2"/>
                  <property name="MESSAGE_ID" expression="get-property('MessageID')"/>
                  <script language="js">var messageID = mc.getProperty('MESSAGE_ID').substring(9,45);
         	       mc.setProperty("RABBIT_MESSAGE_ID", messageID);</script>
                  <property name="rabbitmq.attributes.custom.message.id"
                            expression="get-property('RABBIT_MESSAGE_ID')"
                            scope="axis2"/>
                  <xslt key="xslt-remove-namespace"/>
                  <clone continueParent="true">
                     <target sequence="writeToFile"/>
                  </clone>
                  <send>
                     <endpoint key="rabbit"/>
                  </send>
               </sequence>
            </target>
         </iterate>
         <payloadFactory media-type="xml">
            <format>
               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                                 xmlns:tfom="https://bur.cdmarf.ru/dss/services/tfoms">
                  <soapenv:Body>
                     <tfom:get_inserted_amound_bed>
                        <tfom:clinicID>$1</tfom:clinicID>
                     </tfom:get_inserted_amound_bed>
                  </soapenv:Body>
               </soapenv:Envelope>
            </format>
            <args>
               <arg evaluator="xml" expression="$axis2:CLINIC_ID"/>
            </args>
         </payloadFactory>
         <call blocking="true">
            <endpoint key="dss"/>
         </call>
         <iterate xmlns:tfoms="https://bur.cdmarf.ru/dss/services/tfoms"
                  continueParent="true"
                  expression="//tfoms:AMOUNT_BED"
                  sequential="true">
            <target>
               <sequence>
                  <property name="rabbitmq.attributes.type"
                            value="AMOUNT_BED"
                            scope="axis2"
                            type="STRING"/>
                  <property name="messageType" value="xml" scope="axis2"/>
                  <property name="contentType" value="xml" scope="axis2"/>
                  <property name="MESSAGE_ID" expression="get-property('MessageID')"/>
                  <script language="js">var messageID = mc.getProperty('MESSAGE_ID').substring(9,45);
         	       mc.setProperty("RABBIT_MESSAGE_ID", messageID);</script>
                  <property name="rabbitmq.attributes.custom.message.id"
                            expression="get-property('RABBIT_MESSAGE_ID')"
                            scope="axis2"/>
                  <xslt key="xslt-remove-namespace"/>
                  <clone continueParent="true">
                     <target sequence="writeToFile"/>
                  </clone>
                  <send>
                     <endpoint key="rabbit"/>
                  </send>
               </sequence>
            </target>
         </iterate>
         <respond/>
      </inSequence>
   </target>
   <description/>
</proxy>
                                


Solution

  • For a request like this:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                      xmlns:tfom="bur.cdmarf.ru/dss/services/tfoms">
       <soapenv:Header/>
       <soapenv:Body>
         <tfom:get_inserted_amound_bed> 
            <tfom:clinicID>6048820</tfom:clinicID> 
         </tfom:get_inserted_amound_bed>    
       </soapenv:Body>
    </soapenv:Envelope>
    

    Yo can use this mediators to capture and log the clinic_id value:

         <property name="CLINIC_ID" xmlns:tfom="bur.cdmarf.ru/dss/services/tfoms"
                   expression="//tfom:get_inserted_amound_bed/tfom:clinicID"
                   scope="default"
                   type="STRING"/>
         <log level="custom">
            <property name="CLINIC_ID_PROPERTY_VALUE" expression="get-property('CLINIC_ID')"/>
         </log>
         <log>
            <property name="PAYLOAD" expression="$body"/>
         </log>
    

    In the payload factory mediator use the same expression to capture the clinic id value:

            <args>
               <arg evaluator="xml" expression="get-property('CLINIC_ID')"/>
            </args>