I have a rest API with POST Method where I am posting and receiving success response as JSON format which works absolutely fine. During the failure I receive
Error details: System.Net.WebException: The remote server returned an unexpected response:
(400) Bad Request The creation failed because the name or email address of the is invalid
Which I see in Application log and send port gets suspended. I need to capture this in the BizTalk Orchestration where I need to send email if I get any error response.
As the Error Response is not in JSON format don't know how it can be handled. Any idea?
Enable Routing for failed messages on the Send Port to stop the suspended messages. You might have to update the filter in the send port that subscribes to ErrorReport.FailureCode Exists to exclude your API send port if you only want to handle these in the Orchestration. If you don't have such a port, you might have to create one, and send the failed messages to a NULL adapter or similar.
Have your Orchestration have an scope with an exception block to catch System Exceptions, in there have Exception = SystemException.ToString(); in an Expression shape where Exception is a System.String Variable, and SystemException is the Exception Object Name you defined in the Catch block.
Have logic in your catch block that decides what sort of exception you got, I use a If shape with Exception.Contains("XXXX") where XXXX is text in the exception, or handle it however you want.
Related
I get an exception from the SignalR client application(Exception thrown: 'System.IO.InvalidDataException' in Microsoft.AspNetCore.SignalR.Protocols.Json.dll).
This is happening when the signalR Hub send messages to a channel that the client is not configured to listening on. The functionality that i want is described below:
The Signalr server Hub sends messages into channels like "Test1","Test2","Test3".
The SingalR client want to receive messages only for the Test1 channel because the particular user screen/page is associated only with the Test1 channel's messages. Then, the other two unhandled channels throws exceptions. So, the client needs to listening to all channels that the server sends to? I thought the On<>() method is meant for the client in order to subscribe to the channels where he is interested.
What am i missing?
Thanks in andvance!
Ran into this issue for a SignalR hub connection with angular client and .net 5.0 server. Below is the screen shot of the error details on the server side. In this instance I was sending a decimal as part of the json payload like "value": 8.3. The issue went away once I converted the decimal to a string like this "value": "8.3"
I'm struggling to find any good examples on how to implement error handling with Spring WebFlux.
The use case I want to handle is notifying HTTP clients that a stream has terminated unexpectedly. What I have found it that with the out of the box behaviour, when a stream is terminated, for example by raising a RuntimeException after x items have been processed, is handled too gracefully! The client is flushed all items up until the exception is raised, and then the connection is closed. As far as the client is concerned the request was successful. The following code shows how this has been setup:
public Mono<ServerResponse> getItems(ServerRequest request) {
Counter counter = new Counter(0);
return ServerResponse
.ok()
.contentType(MediaType.APPLICATION_STREAM_JSON)
.body(operations.find(query, Document.class, "myCollection")
.map(it -> {
counter.increment();
if(counter.getCount() > 500) {
throw new RuntimeException("an error has occurred");
}
return it;
}), Document.class);
}
What is the recommended way to handle the error and notify the HTTP client that the stream terminated unexpectedly?
It really depends on how you'd like to communicate that failure to the client. Should the client display some specific error message? Should the client reconnect automatically?
If this is a "business error" that doesn't prevent you from writing to the stream, you could communicate that failure using a specific event type (look at the Server Sent Events spec).
Spring WebFlux supports ServerSentEvent<T>, which allows you to control various fields such as event, id, comment and data (the actual data). Using an Flux::onErrorMap operator, you could write a specific ServerSentEvent that has an "error" event type (look at the ServerSentEvent.builder() for more).
But this is not transparent to the client, as you'd have to subscribe to specific events and change your JavaScript code otherwise you may display error messages as regular messages.
In my TIBCO BW project I have one process which has some activities like mapper, http, jms etc and I have caught activity also. But I want to catch all the errors created by HTTP activity not other activity errors .
Please help me on this .
I can suggest you two solutions.
The first-one consists in catching explicitly the exception from the HTTP activity using an "error" branch
The second-one consists to catch the different exceptions throw by the HTTP activity exceptions (HTTP Client exception, HTTP Server Exception, HTTP Communication Exception)
We have activated health monitoring on our website. Recently we are getting a lot of hack attempts which are caused by bots, but also spawn a lot of server errors.
Exception type: System.Web.HttpException
Exception message: The length of the URL for this request exceeds the configured maxUrlLength value.
Request information:
Request URL: http://www.ourdomain.be/Product/Band/29360" onmousedown="return rwt(this,'','','','7','[CUT_OUT_SOME_STUFF]row ab_button" id="am-b6" href="
User host address: ---.---.47.93
How can I filter these particular events so I don't get 10 emails per second?
Or how can I sanitize the URL before it is handled by the security parts of ASP.NET?
I can't totally repro your error - I get an exception for Illegal characters in path instead. Nevertheless...
Quick and dirty = send your emails to a dummy address and set up a
filter/rule on it so only the ones you want get forwarded to you
Slightly less quick = Use Application_Error with
Server.GetLastError() and Server.ClearError() to inspect and ignore
these
Create your own health monitoring provider, though I think you still
need to use Server.GetLastError to retrieve the exception data. See
http://msdn.microsoft.com/en-us/library/ms227676%28v=vs.85%29.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1
I have a web service method taking multiple parameters.
Therefor the BodyStyle = WebMessageBodyStyle.Wrapped is set.
I want to access this method from a web service client therefor I did add the url of the service method to Reference->Add Services and I get the following error.
"There was an error downloading 'http://localhost:8080/Api/StoreI'.
The request failed with HTTP status 405: Method Not Allowed.
Metadata contains a reference that cannot be resolved: 'http://localhost:8080/Api/StoreI'.
The content type application/json of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8).
If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly.
The first 323 bytes of the response were: '{"ErrorCode":110,"ErrorDetails":null,"Message":"The incoming message has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml', 'Json'.
This can be because a WebContentTypeMapper has not been configured on the binding. See the documentation of WebContentTypeMapper for more details."}'.
The remote server returned an error: (500) Internal Server Error.
If the service is defined in the current solution, try building the solution and adding the service reference again."
What should I do in order to resolve this error?
What are the steps to access a secure web service from a client?
I an new to web services.
A reply would be highly appreciated.
Thanks.
I am not expert but change
BodyStyle = WebMessageBodyStyle.Wrapped
to
BodyStyle = WebMessageBodyStyle.Bare
The usage of the wrapped on the operation description does not add a layer of security on the message body. It simply wraps the request (or the response) in an XML element