BizTalk WCF Request Response Port - sending error handling response to response RRS feed

  • Question

  • Hi, I am having trouble sending error response back to the client in the same 2 way Request Response.

    I have a 2 way Request Response port, on Receive I am receiving Request doing Transformation and sending the Response back to the same 2 way port.

    I am using Exception Handler block, catching system.exception and sending back to same 2 way Request Response port. 

    But this is causing build to fail.

    Error : Must receive before sending a message whose messagetype corresponds to a requestresponse operation on an implemented port.

    How do I send the exception handler message to same 2 way Request Response port ? Please advice


    Wednesday, October 14, 2020 7:12 PM

All replies

  • Is your Receive Shape before the scope or in it?  It needs to be before the scope where you catch the exception and send a response.  In fact I usually don't even put the initiating receive shape for the Orchestration in a scope, as I've only ever once had an exception thrown from that, and it is a real edge case involving a MIME message.
    Wednesday, October 14, 2020 7:57 PM
  • I have my Receive shape on the top and then have created a Scope shape after it.

    I am having problems while sending the System.Exception from Exception handler block to the same 2 way Request Response port.

    Do I need to create a fault message on the same Request Response port ? If so, how to create fault message in Exception handler ? Please advice

    How can I achieve this ?


    • Edited by Dan2890 Wednesday, October 14, 2020 8:05 PM a
    Wednesday, October 14, 2020 8:04 PM
  • Below is how my Orch looks and what all I have tried :

    I am just testing a scenario to expose a web service from orchestration.

    Here is what I do within the orchestration. 

    1. Receive an employee ID as a request
    2. make a sql call to retrive employee data from a table
    3. map the sql response to web service response
    4. return the web service response

    now this is the happy path. but as its a web service, we also want to return a fault, if anything goes wrong, for ex, sql returned error. 

    I added a fault message on the request-response port. added a fault to the same port.

    First I generated the fault message in the exception block but received this compile time error. 

     must receive before sending a fault message on an implemented port

    THIS blog lays down a good insight of the error.

    Following the instructions on the blog, I changed the orchestration path to below. 

    1. Receive Request
    2. Scope Start
    3. Map to Sql Request
    4. Send Sql Request
    5. Receive Sql Response
    6. Set varFlag=0 (varFlag is an int variable)
    7. Exception Block of the scope
    8. If there was an error during the process, it falls to the exception block
    9. within exception block Set varFlag=1
    10. Outside of the exc block I have a Decide shape which looks for either flags and based on that I map to either a websvc response message or exception message
    11. Now it complains of the Sql response message (which is used to map to the web svc response) not being initialized.

    Here are the images of how the orch looks. Any help is appreciated. 


    Wednesday, October 14, 2020 10:27 PM
  • You can't use the SQL message outside of the scope where you receive it, as there is a path where if it goes through the exception block where it might not be initialized.  What you can do in your exception block is to set another variable that contains the exception message which you then map to your  exception response message, as input I usually use the initiating message (even if you aren't mapping anything from it), as that will always be there if the Orchestration has started. 

    The Scope and Exception blocks are basically a Try Catch.

    Monday, October 19, 2020 3:08 AM