none
Extracting fault message or response from the WCF adapter RRS feed

  • Question

  • Hello ,

    I have the following scenario : a client and a server (both Biztalk servers).

    The client implements the orchestration below (basically an orchestration exposed as a WCF service , with a fault port).


    If everything ok , the orchestration will return the MsgOut message , if not , the MsgFault message will be sent to the fault port. The message are below :

    <ns0:MsgOut val="val" corr="corr" xmlns:ns0="http://ConsumeWebService.MsgOut"/>
    <ns0:MsgFault val="val_0" corr="corr_1" xmlns:ns0="http://ConsumeWebService.MsgFault" /> 

    After they reach the Wcf adapter of the client , they will be wrapped in the SOAP envelope , and will look like that :


    Moving now on the server side , I have the Wcf adapter that calls the client orchestration above and receives the response on the same connection . What I want is to strip the MsgOut or MsgFault from the SOAP envelope , type them and send them to the message box. This is done in the transport property :

    In the inbound biztalk message body section , to specify the source of the inbound message body , instead of Body I'm using path with the following XPath expresion :

    /*[local-name()='MsgOut']  | /*[local-name()=’Envelope’]/*[local-name()=’Body’]/*[local-name()=’Fault’]/*[local-name()=’detail’]/*[local-name()=’ExceptionDetail’]/*[local-name()=’Message’]/* 

    After the message is selected , because of the XmlReceive pipeline , the message will be typed .

    Basically I'm trying to select the response (MsgOut) or the fault message (which I can see it in the Message section of the fault envelope ) . The problem is that the fault message inside the SOAP contains the xml serialised version :

    &lt;ns0:MsgFault val="UK" corr="uk" xmlns:ns0="http://ConsumeWebService.MsgFault"&gt;&lt;/ns0:MsgFault&gt;


    Perhaps something might be wrong with my XPath for selecting the fault message( /*[local-name()=’Envelope’]/*[local-name()=’Body’]/*[local-name()=’Fault’]/*[local-name()=’detail’]/*[local-name()=’ExceptionDetail’]/*[local-name()=’Message’]/* ) but , assuming it is ok , I don't know how to push this message as a MsgFault typed message into the Message Box(a conversion in the pipeline , message formatted in a different way by the client , etc)

    Thanks for your time


    Friday, November 25, 2016 6:02 PM

Answers

  • Eventually I did it with Wcf interceptors (after the fault message is created by Biztalk Wcf adapter , before being send to the client I'm overriding the fault creating a new one (with some relevant data from the old one))

    Some links that pointed me to the right direction :

    http://drewdotnet.blogspot.be/2009/05/biztalk-2006-r2-and-wcf-fault-messages.html

    https://weblogs.asp.net/paolopia/writing-a-wcf-message-inspector

    https://www.codit.eu/blog/2012/12/14/how-to-register-wcf-extensions-in-biztalk/

    :-)

    Friday, December 2, 2016 11:16 AM

All replies

  • Is there any way to format the fault soap produced by the Biztalk Wcf adapter ?

    You have the default fault below :

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
    <s:Fault>
    <faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">
    </faultcode>
    <faultstring xml:lang="en-GB">
    &lt;ns0:MsgFault val="UK" corr="uk" xmlns:ns0="http://ConsumeWebService.MsgFault"&gt;&lt;/ns0:MsgFault&gt;
    </faultstring>
    <detail>
    <ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <HelpLink i:nil="true"/>
    <InnerException i:nil="true"/>
    <Message>
    &lt;ns0:MsgFault val="UK" corr="uk" xmlns:ns0="http://ConsumeWebService.MsgFault"&gt;&lt;/ns0:MsgFault&gt;
    </Message>
    <StackTrace>
    at Microsoft.BizTalk.Adapter.Wcf.Runtime.BizTalkAsyncResult.End()&#xD;
    </StackTrace>
    <Type>
    Microsoft.BizTalk.Adapter.Wcf.Runtime.BizTalkNackException
    </Type>
    </ExceptionDetail>
    </detail>
    </s:Fault>
    </s:Body>
    </s:Envelope>

    I want something like :

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
    <s:Fault>
    <faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">My Fault code
    </faultcode>
    <faultstring xml:lang="en-GB">
    &lt;ns0:MsgFault val="UK" corr="uk" xmlns:ns0="http://ConsumeWebService.MsgFault"&gt;&lt;/ns0:MsgFault&gt;
    </faultstring>
    <detail>
    <ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <HelpLink i:nil="true"/>
    <InnerException i:nil="true"/>
    <Message>
    <ns0:MsgFault val="val_0" corr="corr_1" xmlns:ns0="http://ConsumeWebService.MsgFault" /> 
    </Message>
    </ExceptionDetail>
    </detail>
    </s:Fault>
    </s:Body>
    </s:Envelope>

    I want to personalize faultcode and  faultstring with some more friendly client info (than the ones provided by Biztalk)

    I want the fault message inside Message element to be xml and not the string serialized version of the message (It is a fault message produced by my orchestration , it will always be xml valid - a typed fault.

    I want to remove the StackTrace since I will have  it anyway in the orchestration in case of an exception ( and it is not important to the client )

    Thanks


    Wednesday, November 30, 2016 10:21 AM
  • Eventually I did it with Wcf interceptors (after the fault message is created by Biztalk Wcf adapter , before being send to the client I'm overriding the fault creating a new one (with some relevant data from the old one))

    Some links that pointed me to the right direction :

    http://drewdotnet.blogspot.be/2009/05/biztalk-2006-r2-and-wcf-fault-messages.html

    https://weblogs.asp.net/paolopia/writing-a-wcf-message-inspector

    https://www.codit.eu/blog/2012/12/14/how-to-register-wcf-extensions-in-biztalk/

    :-)

    Friday, December 2, 2016 11:16 AM