I am testing the exception handling of my BizTalk 2010 orchestration. The orchestration has one scope shape with one catch shape attached to it.
The scope shape's transaction type is set to 'NONE' so I can work with the .NET exception. Inside the catch is a construct message shape with a message assignment shape. The message assignment shape is using the active message type from the receive shape.
When the orchestration runs it suspends on the send message shape. The error is:
Type System.Xml.XmlDocument in Assembly System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxx is not marked as serializable.
My project is set up such that for testing purposes I can process either an incoming BizTalk message or an XML file (via the test editor.)
I can take the XML that is submitted to the receive shape, save it as an XML file and process the XML file.
To test the exception handling I have purposely
coded a database insert that will fail. The full database error is written to a log file and a new exception is throw with a message like this:
Failed to process BLAH request to completion - Message Processor - Image ID: ABC Note ID: XYZ. When running the XML file, the application throws the error
in the expected place and the error is caught back at the test editor. I am able to serialize the error message in the test editor function.
However, when running from BizTalk I get the error. A correlation set has been defined with these properties:
BTS.ReceivePortName,ErrorReport.ErrorType,ErrorReport.InboundTransportLocation.
The code in the assign shape is as follows.
msgFail = InputMsg;
msgFail(ErrorReport.ErrorType) = "FailedMessage";
msgFail(ErrorReport.Description) = ex.Message;
msgFail(ErrorReport.FailureCategory) = 0;
msgFail(ErrorReport.FailureCode) = "";
msgFail(ErrorReport.InboundTransportLocation) = InputMsg(BTS.InboundTransportLocation);
msgFail(ErrorReport.RoutingFailureReportID) = System.Convert.ToString(System.Guid.NewGuid());
msgFail is the message I am trying to send.
InputMsg is the active message type from the initial receive shape. It is a multi-part message type tied to a schema that validates.
ex is the exception object name in the catch shape. It is of type System.Exception.
I've read many posts about how to set the properties for the scope and catch shapes to be able to use the exception object, but it is still not working.
I am making an assumption that since I can serialize the error message when running from the XML file that my problem is with how my orchestration is getting the exception.
If you have the ESB Toolkit installed you can use that to create your fault messages.
e.g
eSBFault = Microsoft.Practices.ESB.ExceptionHandling.ExceptionMgmt.CreateFaultMessage();
eSBFault.FailureCategory= "General System Exception";
eSBFault.FaultCode = "500";
eSBFault.FaultDescription = orchestrationName + ": " + ex.Message;
eSBFault.FaultSeverity = Microsoft.Practices.ESB.ExceptionHandling.FaultSeverity.Error;
eSBFault.Scope = "Scope Name";
Microsoft.Practices.ESB.ExceptionHandling.ExceptionMgmt.AddMessage(eSBFault, InputMsg);
Note 1: orchestrationName is a variable that was set earlier in the Orchestration
orchestrationName = Microsoft.XLANGs.Core.Service.RootService.Name;
Note 2: Your msgFail is eSBFault in this example, but you can call it msgFail as well. It is of Message Type Microsoft.Practices.ESB.ExceptionHandling.Schemas.Faults.FaultMessage
Related
Blank project repo with problematic code
I have the following code for querying all the supported Audio codec following this article using CodecQuery.FindAllAsync
try
{
var query = new CodecQuery();
var queryResult = await query.FindAllAsync(CodecKind.Audio, CodecCategory.Encoder, "");
var subTypes = queryResult
.SelectMany(q => q.Subtypes)
.ToHashSet();
// Other codes
}
catch (Exception ex)
{
Debug.WriteLine(ex);
throw;
}
As the documentation mentioned,
To specify that all codecs of the specified kind and category should be returned, regardless of what media subtypes are supported, specify an empty string ("") or null for this parameter.
For empty string "", it works for CodecKind.Video but not for Audio (for both CodecCategory of Encoder or Decoder). If I specify a subtype, then it does not crash, for example:
var queryResult = await query.FindAllAsync(CodecKind.Audio, CodecCategory.Encoder, CodecSubtypes.AudioFormatMP3);
What is strange about that is that even though I have a try/catch with generic Exception, the app just crashes through that one and show this instead:
I have tried restarting Windows, uninstall the UWP app and make a clean build. What is happening? How do I query all available audio codecs?
Update: after changing Debug setting, I could trace the error message:
Unhandled exception at 0x00007FFDCE5FD759 (KernelBase.dll) in ******.exe: 0xC0000002: The requested operation is not implemented.
After my testing, the content of this document is correct. When I set “” for the third parameter to find all audio codecs, the code works well. So there is not an error in this document.
You could choose the Debug options, and change Debugger type from Managed Only to Mixed. It won't fix your exception, but you can trace it with the debugger. You could refer to this reply to get more information.
Sometimes when calling the Mastercard MATCH API via the NuGet package MasterCard-Match, I will get a JSON deserialization exception:
Unexpected character encountered while parsing value: <. Path '',
line 0, position 0.
The exception is from MasterCard.Core with an inner exception from Newtonsoft.Json, both have the same message.
It looks like I'm receiving HTML ('<' at line 0, position 0) and the library is trying to deserialize it as JSON. My guess is that the MasterCard API is sending back an HTML error page instead of a JSON error. But I can't step into the function call to "see" the response its getting before throwing the exception.
As per the documentation I create a request map with the provided data and call TerminationInquiryRequest.Create(map), this is the line the exception is thrown. This function call is a black box, I can't step into it, it just throws the exception.
try
{
RequestMap requestMap = CreateRequestMap();
// This line throws the exception
TerminationInquiryRequest apiResponse = TerminationInquiryRequest.Create(requestMap);
}
catch(Exception e)
{
// Exception handling
}
I've made over 11,000+ calls using this library and only 32 have had this error, but of course I get to hear about it every time it happens.
Is there any way to debug libraries that I'm not aware of, or a way to view the response that the library is getting from the API?
I already have some logic to wait and retry the call if it fails.
At work I have encountered a problem with EvoPdf for DotNet client where it won't actually convert the html because of the following exception:
An error occured. Initialization failed: Insufficient data
The stack trace shows the following:
at am.aa()
at EvoPdf.HtmlToPdfClient.HtmlToPdfConverter.ConvertHtml(String html, String baseUrl)
at evoPdfTest.Program.Main(String[] args) in D:\git\evoPdfTest\evoPdfTest\Program.cs:line 32
This of course makes no sense, because in order to verify it wasn't anything I did, I decided to make a small console app as follows (also this same error occurs in their demo code as well.
var pdfConverter = new HtmlToPdfConverter(myIpString, myPort);
var paragraphHtml = $$"<!DOCTYPE html><html> <body> The content of the body element is displayed in your browser.</body></html> "";
pdfConverter.LicenseKey = myKey;
// Set an adddional delay in seconds to wait for JavaScript or AJAX calls after page load completed
// Set this property to 0 if you don't need to wait for such asynchcronous operations to finish
pdfConverter.ConversionDelay = 2;
// set PDF page size
pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
// set PDF page orientation
pdfConverter.PdfDocumentOptions.PdfPageOrientation = PdfPageOrientation.Portrait;
var pdfBytes = pdfConverter.ConvertHtml(paragraphHtml, null);
Where am I going wrong, and is this just a case of a superemly poorly written error message?
For anyone getting this error in the future:
An error occured. Initialization failed: Insufficient data
This occurs due to a mismatch in versions. In our case, we had an Azure Function running version 8.0.0 of the EvoPDF NuGet library and an Azure Cloud Application endpoint running version 7.5.0. Ensure that all services are running the same version.
I'm tryng to write binary data using Windows Proximity Device API.
I can discover NFC tags and I can read NDEF messages from TAGs, writted at Android Phone.
But when I try to set up a PublishBinaryMessage, I always receive ArgumentException (Value does not fall within the expected range) when I use this messageTypes:
"NDEF", "WriteableTag", or any other described in https://msdn.microsoft.com/en-us/library/windows/apps/hh701129.aspx
except "Windows.someSubtype". But in this case, my TAG isn't writed.
I get ArgumentException with "NDEF.someSubtype", but the message is "Message "The parameter is incorrect.This ProximityDevice does not support the passed in messageType: NDEF.someSubtype"
The code:
//Does not work - Argument Exception - "Value does not fall within the expected range"
messageID = proximityDevice.PublishBinaryMessage("NDEF", Encoding.UTF8.GetBytes("lorem ipsum").AsBuffer(), MessageTransmittedHandler);
//Does not work - Argument Exception - "The parameter is incorrect"
messageID = proximityDevice.PublishBinaryMessage("NDEF.something", Encoding.UTF8.GetBytes("lorem ipsum").AsBuffer(), MessageTransmittedHandler);
//No Exception, but never writes on device.
messageID = proximityDevice.PublishBinaryMessage("Windows.something", Encoding.UTF8.GetBytes("lorem ipsum").AsBuffer(), MessageTransmittedHandler);
The input Buffer was wrong. In case of NDEF messages, the API docs say:
The message contents are properly formatted NDEF records
So, using the ndef-nfc library from Andijac (https://github.com/andijakl/ndef-nfc), the binary message was properly published.
I have an asp.net project in which, I would like to query DBPedia.
Using the following code I am getting an error:
public string testEndpoint()
{
//TEST02
SparqlRemoteEndpoint endpoint = new SparqlRemoteEndpoint(new Uri("http://dbpedia.org/sparql"), "http://dbpedia.org");
string res = "";
//Make a SELECT query against the Endpoint
SparqlResultSet results = endpoint.QueryWithResultSet("SELECT ?year WHERE {dbpedia:Rihanna dbpedia-owl:birthYear ?year}");
foreach (SparqlResult result in results)
{
res = result.ToString();
Console.WriteLine(result.ToString());}
Error message: "An exception of type 'System.Xml.XmlException' occurred in dotNetRDF.dll but was not handled in user code".
Even if I handle the exception the method cannot be executed. Regarding the details it says that there is an invalid XML-version 1.1.
As the XML comes from DBPedia I don't know how to change the xml version or how else I can handle this problem.
Virtuoso, which is the triple store used behind the dbpedia SPARQL endpoint, has updated its XML result generation. They replaced the XML version 1.0 with 1.1 in this commit. This causes the exception in the dotNetRDF parser.
Later on Virtuoso reverted the changes in the XML header. Hopefully DBPedia will update their binaries soon, so the old XML header appears again in the SPARQL results.
Source: http://github.com/openlink/virtuoso-opensource/issues/405