OSB12c : Fixed Length Message Type
We can easily transform flat file of fixed length into valid xml using
native format builder in OSB-12c.
Sample use-case:
1. Send flat file with fixed length to proxy service.
2. Include nXSD schema in proxy service in order to convert flat file
into XML.
Create new folder inside MessageType_Service
File -> New -> Folder -> FixedLength_MessageTypeServices along with sub folders
Create new pipeline
in design view
Specify Messaging type as below
Request: Text
Response: XML
Crate a proxy service with ‘http’
transport protocol
Design view (right click) ->
Insert Transport -> HTTP
Specify Service name and transport for proxy service.
Service name: FixedLengthProxyService
Transport: http
Messaging Req: Text
Resp: XML
Link this created proxy service with
pipeline.
FixedLengthProxyService ->
FixedLength_MessageTypePipeline -> FixedLength_MockResponse
Next step is to create nXSD schema to convert flat file of fixed length into XML using native format builder.
FixedFile_MessageTypeService -> Resources -> native format (Right click) -> nXSD schema.
Specify name for nXSD schema
Name: FixedFileToXSD
Choose Type: Fixed Length
Select sample fixed length file from specified
location
In above example we have selected
sample file by name FixedLength.txt from desktop location.
C:\Users\Tapan\desktop\FixedLength.txt
Below is content of FixedLength.txt which is
having each column of length 42.
Next specify record organization as below
* File contains multiple record instances
* Multiple records are of single type
Specify child element name for
Root-Element
Enter Name for element that will
represent record: Fixed Length
Next step is to
specify a field length by clicking at desired position on ruler.
In above example we have specified 3 fields of
length 20,31,42 respectively.
As shown above we can locate field properties.
Click on Next
We can see that schema got generated for
specified flat file.
Next step is to create stubs and FixedLength_MockResponse proxy service to get some valid static response.
Create Mock Response Service with below specification.
Name: FixedLengthFile_MockResponseProxyService
Transport: local
Service Type: Any XML
Save incoming request in variable called $incomingBody using ‘Assign’ activity.
Save transport user-header value which is coming
in $inbound into a variable called ‘$IncomingMessageType’
Next add a ‘If’ condition with logic
as below
data ($IncomingMessageType)
=”FixedFileLength”
Next add a ‘Replace’ action inside If
condition with expression as below
<FinalResponse>
<Code>000</Code>
<Desc>FixedLengthFile Message
type tested successfully. </Desc>
<ChangedFileBody> {$body/*:
Root-Element} </ChangedFileBody>
</FinalResponse>
Add a Reply node with status ‘with success’
Add a route node and route incoming request to Mock service.
Next add a nXSD translate node to convert native
file into XML, and save the converted XML body into a variable called
‘FixedFileBody’.
Add a insert node in order to send content of $FixedFileBody into mock service.
Next add a ‘Transport Header’
activity and assign a user-header with name and value as below
Direction: outbound-request
Action: set
Name: MessageType
Protocol: http
Value: FixedLengthFile
Deploy service into standalone local weblogic server.
Once deployment is successful, we can locate
service in sbconsole.
Next run Fixed_lengthPipeline
A pop up window will get open in which we need to
select flat file which we use for testing.
Once the execution of request is success , we can see response as below
We can see that flat file is converted into XML
structure and the same we have populated in final response.






































Comments
Post a Comment