none
BizTalk <-> REST service : WCF-WebHttp Empty response body RRS feed

  • Question

  • Hello all,

    I am trying to execute 'PUT' on a REST service. REST Service sends a empty Response Body with Status Code and Status Description in message Headers.

    I am facing challenges in handling empty message body in BizTalk Orchestration.

    I have a Dynamic WebHttp Request-response port.  Send is Json-Xml pipeline. Receive is Pass-through.

    Message type for response in Orchestration is XmlDocument. 

    I get error "Root element is missing" on Receive Port.

    If anyone have idea how to handle this situation, please let me know.

    Many Thanks.

    Tuesday, August 16, 2016 5:38 AM

Answers

  • Go through this article it is doing what you are trying to accommodate ,you shall be able to accomplish this with 2 way send ports 

    https://blog.tallan.com/2015/02/11/biztalk-orchestration-handling-webhttp-rest-get-requests/

    Hello Pushpendra,

    Yes I tried setting allow unrecognized message to true. But given me Object Reference error.



    Regards Pushpendra K Singh



    Friday, August 19, 2016 8:12 AM
  • Hi Supriya,


     Do you require/want response from destination service? If no then go for Oneway  port . 

    If you need response from the destination service then empty response is coming in which scenario? is it during failure/exception or in success scenario or in both the cases?



    Manish

    Wednesday, August 17, 2016 5:23 AM
  • Hi Supriya,

    Would you please confirm you tried my suggestion? I have faced the same scenario many times and using a one way port instead of a req/resp WORKS.

    BizTalk will throw an exception if the response is NOT 200ok, so you can catch it and log into ESB as you require.

    Please confirm you attempted my suggestion, and why did it not answer your question? 


    My Technet Articles

    If you like this or another reply, vote it up!
    If you think this or another reply answers the original question, mark it or propose it as an answer.


    Mauricio Feijo
    www.mauriciofeijo.com


    Thursday, August 18, 2016 1:44 PM

All replies

  • Hi Supriya,

    Root element is missing

    Currently, you are getting this error in map execution or component execution ?

    - If you have received the response in orchestration then use map (response to some schema with hard code / constants mapping)

    - This error you will get when no mapping is happening / msg is not constructed / empty.

    Thanks, SMSVikasK

    Tuesday, August 16, 2016 6:09 AM
  • Hello Vikas,

    Like I said in my post I am getting this error on Response port.

    REST service sends the Empty Message body in response to my PUT request. Details are in Response header such as Status Code (200, 400 etc.) with Status Description.


    Tuesday, August 16, 2016 6:35 AM
  • Hi Supriya,

    Can you please paste the full error ? 

    Are you constructing / using response message received from the port in your orchestration?

    Thanks, SMSVikasK


    • Edited by SMSVikasK Tuesday, August 16, 2016 7:08 AM
    Tuesday, August 16, 2016 7:04 AM
  • Hi,

    Use the XMLReceive on the receive pipeline instead of pass through for your rest service 2 way send  port. and set allow unrecornized message property on the receive pipeline to true. It shall work.


    Regards Pushpendra K Singh



    Tuesday, August 16, 2016 2:47 PM
  • The correct way to do this is to use a 1 way port, not a request response.

    Recreate your port as 1 way and you are good to go.


    My Technet Articles

    If you like this or another reply, vote it up!
    If you think this or another reply answers the original question, mark it or propose it as an answer.


    Mauricio Feijo
    www.mauriciofeijo.com

    Tuesday, August 16, 2016 4:52 PM
  • Hi Supriya,


     Do you require/want response from destination service? If no then go for Oneway  port . 

    If you need response from the destination service then empty response is coming in which scenario? is it during failure/exception or in success scenario or in both the cases?



    Manish

    Wednesday, August 17, 2016 5:23 AM
  • Hi Supriya,

    I am facing challenges in handling empty message body in BizTalk Orchestration.

    > Can you elaborate what steps have you taken and what challenges are you facing??

    Message type for response in Orchestration is XmlDocument.

    > Well are you sure you have created a xml document which is not empty, meaning is it well formed?? Generally xmlDocument is assigned value using the LoadXml orLoad method, can you try logging the xmldocument and see if it is empty?? If you are using a map construct the message make sure that map returns a response which is again a well formed xml with root node: if this doesnot happen, your map is the culprit.try debugging it and see if it helps.

    Now the error which you face on the response part of the port is that the message which was received in this case is invalid so you need to make sure that the message sent to the response part of the port is a well formed xml   Once you take care ofr it the error will gop away.

    Regards,


    Mandar Dharmadhikari

    Wednesday, August 17, 2016 8:05 AM
  • Hello all,

    I will try to give out as much details as possible.

    I am connecting to REST service which takes JSON array. -- > This works.

    REST service sends a Empty Response body with Status Code and Description in WCF Inbound HTTP headers. --> works too.

    I am trying to catch this Empty Response body in Orchestration. Check the Status Code. If it is anything other than 200/OK, log into ESB portal. --> Everything goes wrong here.  I don't know how to receive this empty message body.


    Thursday, August 18, 2016 8:56 AM
  • Hi Supriya,

    Is it necessary to use the two way port to send the data and recieve it??

    I am trying to catch this Empty Response body in Orchestration. Check the Status Code. If it is anything other than 200/OK, log into ESB portal. --> Everything goes wrong here.  I don't know how to receive this empty message body.

    REST service sends a Empty Response body with Status Code and Description in WCF Inbound HTTP headers. --> works too.

    These two sound a little bit contrasting...

    Because if the empty body with a right set ofHTTPcode is being read so should be the case for the empty message body with Status other than 200...Can you elaborate what exactly is that you do before you log the message to ESB portal...something goes wrong here before inserting to the ESB ..looks like that from the description that you have provided..

    Regards,


    Mandar Dharmadhikari


    Thursday, August 18, 2016 9:11 AM
  • Hi,

    Use the XMLReceive on the receive pipeline instead of pass through for your rest service 2 way send  port. and set allow unrecornized message property on the receive pipeline to true. It shall work.


    Regards Pushpendra K Singh



    Hi Supriya,

    Did you try changing your Restfult service BizTalk send port>>Receive pipeline from pass-throuh to XMLReceive and and set allow unrecornized message property to true?


    Regards Pushpendra K Singh

    Thursday, August 18, 2016 12:16 PM
  • Hi Supriya,

    Would you please confirm you tried my suggestion? I have faced the same scenario many times and using a one way port instead of a req/resp WORKS.

    BizTalk will throw an exception if the response is NOT 200ok, so you can catch it and log into ESB as you require.

    Please confirm you attempted my suggestion, and why did it not answer your question? 


    My Technet Articles

    If you like this or another reply, vote it up!
    If you think this or another reply answers the original question, mark it or propose it as an answer.


    Mauricio Feijo
    www.mauriciofeijo.com


    Thursday, August 18, 2016 1:44 PM
  • Hello Mauricio, Sorry for late reply. Yesterday was a crazy day.

    I think you are right. One way port is the only option. 

    I will try it today and let you know.

    Friday, August 19, 2016 2:03 AM
  • Hello Pushpendra,

    Yes I tried setting allow unrecognized message to true. But given me Object Reference error.

    Friday, August 19, 2016 2:06 AM
  • Hello Mauricio,

    Yes, your solution worked best.

    But when I send the incorrect data, I get System.WebException from REST service. 

    I have handled System.WebException in my Orchestration, but still it wont catch the Exception.

    I have routing Enabled on port, so Exception is logged into ESB portal.

    But why wont my Orchestration catch it ??

    Friday, August 19, 2016 3:45 AM
  • Hi ,you had the issue of your send port getting suspended initially, did your send port stop suspending after changing the send port rcv pipeline. I assume the object reference error you may have got shall be on your suspended orchestration . Let me know.

    Regards Pushpendra K Singh

    Friday, August 19, 2016 8:00 AM
  • Go through this article it is doing what you are trying to accommodate ,you shall be able to accomplish this with 2 way send ports 

    https://blog.tallan.com/2015/02/11/biztalk-orchestration-handling-webhttp-rest-get-requests/

    Hello Pushpendra,

    Yes I tried setting allow unrecognized message to true. But given me Object Reference error.



    Regards Pushpendra K Singh



    Friday, August 19, 2016 8:12 AM
  • Hello Pushpendra, 

    Thanks it worked. Now I am able to check if Message was received by REST service or not.

    With one way port it was like a blind-send. :(

    Monday, August 29, 2016 4:50 AM
  • Hi Supriya/Pushpendra,

    I am encountering the same scenario where I am using BizTalk 2013 R2 to invoke a REST API with JSON format.

    I have used Request-Response WCF-WebHttp port. The REST API behaves like below.

    When I post a JSON object, it comes back with

    201: Created (with actual payload of the object created.)

    204: No content (when an a object is updated)

    400: Bad request (with Error list payload)

    What have you done exactly to handle empty payload and also any error response etc. 

    Can you please elaborate on what you have done on handling the response. What type object do you have in your orcestration to handle the empty response?

    BTW I have used JSON Encoder on the request side which works fine and the object is created. Its just that I want to capture the response.

    Thanks a lot in advance.

    Thursday, August 3, 2017 3:35 AM
  • Hi Folks,

    This issue is fixed in CU6 for BTS2013 R2 and CU2 for BTS2016.

    https://support.microsoft.com/en-in/help/4020011/fix-wcf-webhttp-two-way-send-response-responds-with-an-empty-message-a

    Regards,

    Vikingsss

    Thursday, October 5, 2017 1:32 PM