Custom ESB Dispatcher pipeline component return null message

Answered Custom ESB Dispatcher pipeline component return null message

  • Tuesday, July 17, 2012 11:03 AM
     
     

    Hello Everybody,

    I have developed custom uddi resolver, the resolver works like the Microsoft uddi resolver except it throw a soap exception if the provided service key  is not valid.

    I have developed a new ESB dispatcher pipeline component. the new component check for the thrown soap exception and create new message

    as in the following code

    if (exception.Message == "There is no configuration with the provided value in UDDI Registry")
                    {
                        XmlDocument newFaultDocument = new XmlDocument();
                        string systemPropertiesNamespace = @"http://schemas.microsoft.com/BizTalk/2003/system-properties";
                        string MessageNameSpace = "http://www.w3.org/2005/08/addressing/soap/fault";
                        string MessageType = MessageNameSpace + "#" + "Fault";
                        newFaultDocument.LoadXml("<Fault xmlns=\"http://www.w3.org/2005/08/addressing/soap/fault\">" +
                            "<FaultCode>ERR_UDDI_INVALID_KEY</FaultCode><FaultDescription>" + exception.Message + "</FaultDescription></Fault>");
                        byte[] outPutBytes = System.Text.Encoding.ASCII.GetBytes(newFaultDocument.OuterXml);
                        MemoryStream ms = new MemoryStream();
                        ms.Write(outPutBytes, 0, outPutBytes.Length);
                        msg.BodyPart.Data = ms;
                        msg.Context.Promote("MessageType", systemPropertiesNamespace, MessageType);
                    Label_ProcessError:
                        itinerary.Advance(msg, context, itineraryStep);
                        itinerary.ActivateServiceInstance(itineraryStep);
                        IMessagingService service = MessagingServiceFactory.Create(itineraryStep);
                        if (service == null)
                        {
                            throw new ApplicationException(Microsoft.Practices.ESB.PipelineComponents.Exceptions.GetErrorDescription(0x20f5e));
                        }
                        msg = service.Execute(context, msg, (itineraryStep.ResolverCollection.Count > 0) ? itineraryStep.ResolverCollection[0] : string.Empty, itineraryStep);
                        if (service.ShouldAdvanceStep(itineraryStep, msg))
                        {

                            goto Label_ProcessError;
                        }
                        if (itinerary != null)
                        {
                            itinerary.Write(msg);
                        }
                        message = msg;
                        message.Context = msg.Context;
                        message.BodyPart.Data = ms;
                    }
                    else
                    {
                        EventLogger.LogMessage(EventFormatter.FormatEvent(MethodBase.GetCurrentMethod(), exception), EventLogEntryType.Error, 0x13b0);
                        throw;
                    } 

    in my itinerary i check for the MessgeType properties if contains "http://www.w3.org/2005/08/addressing/soap/fault" then writes the error message in a specific folder else continue the normal path for invoking the wcf service. 

    when route the error message to the folder the file is always empty which means that the message is got empty from the custom esb dispatcher.

    any ideas?

                            

    hassan ibrahim

All Replies

  • Thursday, July 19, 2012 8:01 AM
     
     Answered
    you need to reset the stream position to 0.