Forum Stats

  • 3,839,730 Users
  • 2,262,532 Discussions
  • 7,901,050 Comments

Discussions

File Adapter

661614
661614 Member Posts: 23
edited Oct 3, 2008 1:10AM in SOA Suite Discusssions
Hi ,

I have to write a BPEL process where user provide an EIn as input .
That BPEL process read a txt file ( where EIN and Name field exist ) through File Adapter .

Now the BPEl process check the user provide EIN with File content .

If the user provide EIN match with File content EIN then the Name of regading EIN will display as output , otherwise
it will show " No Data Exist " .

Please help me regarding this as early as possible .
Tagged:

Answers

  • I got a bit lost in your explaination, this is how I understand your use case.

    * BPEL process recieves a EIN (Employer Identification Number). The BPEL process is invoked via a web service.
    * BPEL needs to read a file based on this EIN number.
    * BPEL checks the content of the file for matches and returns "No Data Exists" if there is no match, otherwise display the output.

    If this is the case then create a xsd for the input and use this when creating the BPEL process. Once you have the xsd for the input and output perform the following steps.

    * Create a synchronous BPEL process using the xsd created above for the request and response.
    * Create a partner link using the file adapter, make sure you use the synchronous read
    * Perform your logic

    hope this gives you a start.

    cheers
    James
  • 661614
    661614 Member Posts: 23
    edited Sep 25, 2008 12:33AM
    Hi James ,

    Thanks a lot .
    I have done nearly 90 % .
    I have stucked in time of comparision between 2 EIN field ( one from user provide another from File ) .
    I have used Switch case ( where condition is when output var of File Adapter partnerlink = input variable of BPEL process ) ,
    then i copy other element of output var of File Adapter partnerlink to output variable
    and otherwise assign ' No Data Exist ' to Error element of output variable .

    But all the time it is showing ' No Data Exist ' whenever i have provide that EIn which is exist in File .

    Is switch case use in this matter is ok or i have to use anything else ?

    or i have done any wrong in switch case ?

    I need your help .

    But after all Thanks a lot .
  • Switch is the right activity to use, and should work.

    * What is the condition in your switch statement for going down the 'No Data Exists'.
    * If you look at the BPEL process does it go down the correct switch path, as there could be an issue assigning with assigning variables in this switch not some much with the switch condition itself. Sad but true usually the biggest issue in switches is the developer putting the condition in the wrong switch.
    * Make sure that there are no leading spaces / characters for the file adapter partnerlink data.
    * Make sure that the variable that you are comparing to is populated.

    cheers
    James
  • 661614
    661614 Member Posts: 23
    Hi James ,

    In case condition i provide condition as

    output variable of Invoke ( which invokes File Adaptor Partnerlink ) = input variable ( user provide data )
    then
    assign Name element of Invoke output variable to Name element of output variable .

    in Otherwise
    assign ' No Data Exist ' expression to Error element of output variable.

    code as per :

    <switch name="Switch_1">
    <case condition="bpws:getVariableData('Invoke_1_SynchRead_OutputVariable','Root-Element','/ns3:Root-Element/ns3:Address/ns3:City') = bpws:getVariableData('inputVariable','payload','/ns2:InputVar/ns2:City')">
    <assign name="Assign_1">
    <copy>
    <from variable="Invoke_1_SynchRead_OutputVariable"
    part="Root-Element"
    query="/ns3:Root-Element/ns3:Address/ns3:Name"/>
    <to variable="outputVariable" part="payload"
    query="/ns2:OutputVar/ns2:Name"/>
    </copy>
    </assign>
    </case>
    <otherwise>
    <assign name="Assign_2">
    <copy>
    <from expression="'No Data Exist'"/>
    <to variable="outputVariable" part="payload"
    query="/ns2:OutputVar/ns2:Error"/>
    </copy>
    </assign>
    </otherwise>
    </switch>

    If you couldn't understand anything from this please let me know .

    Thanks
    Angshuman
  • it all looks ok, I just wonder if you take the case out of it, e.g.

    upper(bpws:getVariableData('Invoke_1_SynchRead_OutputVariable','Root-Element','/ns3:Root-Element/ns3:Address/ns3:City')) = upper(bpws:getVariableData('inputVariable','payload','/ns2:InputVar/ns2:City'))

    Also I see that you write the output to different variables, e.g. name for 'data found', or error for 'No data'. I suggest that you populate error regardless, if you find data populate it with 'Data Found'

    If you could post the Audit xml of this switch this could be helpful because I can't see the data being validated.

    cheers
    James
  • 661614
    661614 Member Posts: 23
    Hi James ,

    If there is 1 data then it is performing fine .


    I have facing the problem when there is more than 1 data in the File .

    when i am comaparing ( via Switch Case ) the user provide EIN with the EIN in the file then i think i have to do this within a loop for more than 1 data in the file .

    but i couldn't understand how i can do this .

    Please help me regarding this .

    Angshuman
  • Oh, sorry my bad.

    You can do a while loop using the expresssion count-node to loop through each row.

    But I don't really understnd your use case. Is know that there are multiple rows in the file and you want to check if each row is the same as user input, what what it the desired result, e.g. do you write the rows to a file, service or what.

    If you want the xml doc that has only the matched rows you could do this in a transform, you can to the choose or if operation that only maps matched rows.

    cheers
    James
  • 661614
    661614 Member Posts: 23
    Hi James ,

    Ya I have multiple data in the file and i have to match the user provide data with File data .
    and i have to show as a output the matched rows .

    I have used while loop to read the rows of file . I am sending you the BPEL process which i made , I think it will be better to understand you what i have made .



    <?xml version = "1.0" encoding = "UTF-8" ?>
    <!--
    Purpose: Synchronous BPEL Process
    -->
    <process name="BPELProcesstest"
    targetNamespace="http://xmlns.oracle.com/BPELProcesstest"
    xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
    xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
    xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
    xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
    xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:client="http://xmlns.oracle.com/BPELProcesstest"
    xmlns:ora="http://schemas.oracle.com/xpath/extension"
    xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
    xmlns:ns1="http://xmlns.oracle.com/pcbpel/adapter/file/Check/"
    xmlns:ehdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.esb.server.headers.ESBHeaderFunctions"
    xmlns:ns3="http://www.w3schools.com"
    xmlns:ns2="http://TargetNamespace.com/Check"
    xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
    xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc">
    <!--

    PARTNERLINKS
    List of services participating in this BPEL process
    -->
    <partnerLinks>
    <!--
    The 'client' role represents the requester of this service. It is
    used for callback. The location and correlation information associated
    with the client role are automatically set using WS-Addressing.
    -->
    <partnerLink name="client" partnerLinkType="client:BPELProcesstest"
    myRole="BPELProcesstestProvider"/>
    <partnerLink name="Check" partnerRole="SynchRead_role"
    partnerLinkType="ns1:SynchRead_plt"/>
    </partnerLinks>
    <!--

    VARIABLES
    List of messages and XML documents used within this BPEL process
    -->
    <variables>
    <!-- Reference to the message passed as input during initiation -->
    <variable name="inputVariable"
    messageType="client:BPELProcesstestRequestMessage"/>
    <!-- Reference to the message that will be returned to the requester-->
    <variable name="outputVariable"
    messageType="client:BPELProcesstestResponseMessage"/>
    <variable name="Invoke_1_SynchRead_InputVariable"
    messageType="ns1:Empty_msg"/>
    <variable name="Invoke_1_SynchRead_OutputVariable"
    messageType="ns1:Root-Element_msg"/>
    <variable name="CurrentRecord" type="xsd:int"/>
    <variable name="NumberOfRecord" type="xsd:int"/>
    </variables>
    <!--
    ORCHESTRATION LOGIC
    Set of activities coordinating the flow of messages across the
    services integrated within this business process

    -->
    <sequence name="main">
    <!-- Receive input from requestor. (Note: This maps to operation defined in BPELProcesstest.wsdl) -->
    <receive name="receiveInput" partnerLink="client"
    portType="client:BPELProcesstest" operation="process"
    variable="inputVariable" createInstance="yes"/>
    <!-- Generate reply to synchronous request -->
    <invoke name="InvokeFileAdaptor" partnerLink="Check"
    portType="ns1:SynchRead_ptt" operation="SynchRead"
    inputVariable="Invoke_1_SynchRead_InputVariable"
    outputVariable="Invoke_1_SynchRead_OutputVariable"/>
    <assign name="AssignVariable">
    <copy>
    <from expression="ora:countNodes(bpws:getVariableData('Invoke_1_SynchRead_OutputVariable','Root-Element','/ns2:Root-Element/ns2:Record'))"/>
    <to variable="NumberOfRecord"/>
    </copy>
    <copy>
    <from expression="1"/>
    <to variable="CurrentRecord"/>
    </copy>
    </assign>
    <while name="While_1"
    condition="bpws:getVariableData('CurrentRecord') &lt;= bpws:getVariableData('NumberOfRecord')">
    <switch name="Switch_1">
    <case condition="bpws:getVariableData('inputVariable','payload','/ns3:InputVar/ns3:EIN') = bpws:getVariableData('Invoke_1_SynchRead_OutputVariable','Root-Element',concat('/ns2:Root-Element/ns2:Record[',bpws:getVariableData('CurrentRecord'),']/ns2:EIN'))">
    <sequence name="Sequence_1">
    <assign name="AssignDetails">
    <copy>
    <from expression="bpws:getVariableData('Invoke_1_SynchRead_OutputVariable','Root-Element',concat('/ns2:Root-Element/ns2:Record[',bpws:getVariableData('CurrentRecord'),']/ns2:Name'))"/>
    <to variable="outputVariable" part="payload"
    query="/ns3:OutputVar/ns3:Name"/>
    </copy>
    <copy>
    <from expression="bpws:getVariableData('Invoke_1_SynchRead_OutputVariable','Root-Element',concat('/ns2:Root-Element/ns2:Record[',bpws:getVariableData('CurrentRecord'),']/ns2:EmailID'))"/>
    <to variable="outputVariable" part="payload"
    query="/ns3:OutputVar/ns3:EmailID"/>
    </copy>
    </assign>
    <assign name="AssignIncreTotalCount">
    <copy>
    <from expression="bpws:getVariableData('NumberOfRecord') + 1"/>
    <to variable="CurrentRecord"/>
    </copy>
    </assign>
    </sequence>
    </case>
    <otherwise>
    <sequence name="Sequence_2">
    <assign name="AssignNOFound">
    <copy>
    <from expression="'No data Exist '"/>
    <to variable="outputVariable" part="payload"
    query="/ns3:OutputVar/ns3:Error"/>
    </copy>
    </assign>
    <assign name="AssignIncreCurrentCount">
    <copy>
    <from expression="bpws:getVariableData('CurrentRecord') + 1"/>
    <to variable="CurrentRecord"/>
    </copy>
    </assign>
    </sequence>
    </otherwise>
    </switch>
    </while>
    <reply name="replyOutput" partnerLink="client"
    portType="client:BPELProcesstest" operation="process"
    variable="outputVariable"/>
    </sequence>
    </process>


    and error is showing in the BPEL console like the following


    <Faulthttp://schemas.xmlsoap.org/soap/envelope/>
    <faultcode>env:Server</faultcode>
    <faultstring>ORABPEL-09500 XPath expression failed to execute. Error while processing xpath expression, the expression is "ora:countNodes(bpws:getVariableData('Invoke_1_SynchRead_OutputVariable','Root-Element','/ns2:Root-Element/ns2:Record'))", the reason is FOTY0001: type error. Please verify the xpath query. </faultstring>
    </Fault>

    Please help me ............
  • sorry for the delay, you get this error if you have given the wrong data type. Try setting NumberOfRecord and CurrentRecord to integer

    cheers
    James
  • 661614
    661614 Member Posts: 23
    Hi James ,

    Sory for late reply .
    I have successful complete that work , though i have to change a lot for that .
    But , thanks a lot , i never forget your help from beginning .
This discussion has been closed.