Skip to content

Instantly share code, notes, and snippets.

@ricston-git
Created February 9, 2013 19:46
Show Gist options
  • Save ricston-git/4746752 to your computer and use it in GitHub Desktop.
Save ricston-git/4746752 to your computer and use it in GitHub Desktop.
<spring:bean id="isoMessageFactory" class="com.solab.iso8583.MessageFactory">
<spring:property name="configPath" value="j8583.xml"/>
</spring:bean>
<flow name="Iso8583Flow">
<vm:inbound-endpoint path="iso8583.service" exchange-pattern="request-response"/>
<iso8583:iso8583-to-message-transformer>
<spring:property name="messageFactory" ref="isoMessageFactory"/>
<spring:property name="isoHeaderLength" value="4"/>
</iso8583:iso8583-to-message-transformer>
<script:transformer>
<script:script engine="groovy">
payload.put(39, new org.mule.module.iso8583.Field().setType(org.mule.module.iso8583.FieldType.NUMERIC).setValue('00').setLength(2))
return payload
</script:script>
</script:transformer>
<message-properties-transformer scope="outbound">
<add-message-property key="iso8583.mti" value="0810"/>
</message-properties-transformer>
<iso8583:message-to-iso8583-transformer>
<spring:property name="messageFactory" ref="isoMessageFactory"/>
</iso8583:message-to-iso8583-transformer>
</flow>
// [Header, MTI = 0800, Bitmap, Field 7 = 1226124404, field 11 = 102, Field 70 = 301]
private static final byte[] ECHO_REQUEST = { 0x30, 0x30, 0x35, 0x35, 0x30, 0x38, 0x30, 0x30, 0x38, 0x32, 0x32, 0x30, 0x30,
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x34,
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
0x30, 0x31, 0x32, 0x32, 0x36, 0x31, 0x32, 0x34, 0x34, 0x30, 0x34, 0x30, 0x30,
0x30, 0x31, 0x30, 0x32, 0x33, 0x30, 0x31 };
// [Header, MTI = 0810, Bitmap, Field 7 = 1226124404, field 11 = 102, Field 35 = 00, Field 70 = 301]
private static final byte[] ECHO_REPLY = { 0x30, 0x30, 0x35, 0x35, 0x30, 0x38, 0x31, 0x30, 0x38, 0x32, 0x32, 0x30, 0x30,
0x30, 0x30, 0x30, 0x30, 0x32, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x34,
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
0x30, 0x31, 0x32, 0x32, 0x36, 0x31, 0x32, 0x34, 0x34, 0x30, 0x34, 0x30, 0x30,
0x30, 0x31, 0x30, 0x32, 0x30, 0x30, 0x33, 0x30, 0x31 };
protected String getConfigResources() {
return "iso8583-functional-test-config.xml";
}
@Test
public void testIso8583Service() throws Exception {
MuleClient client = muleContext.getClient();
MuleMessage result = client.send("vm://iso8583.service", new DefaultMuleMessage(ECHO_REQUEST, muleContext));
assertArrayEquals(ECHO_REPLY, (byte[]) result.getPayload());
}
}
<j8583-config>
<header type="0810">0055</header>
<parse type="0800">
<field num="7" type="NUMERIC" length="10" />
<field num="11" type="NUMERIC" length="6"/>
<field num="70" type="ALPHA" length="3"/>
</parse>
</j8583-config>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment