How to properly handle Axis2 generated exceptions with a REST client - axis2

I am using Axis2 v1.6.1 and Resty as a rest client. If I purposely send a malformed request that Axis2 cannot parse, for example, sending "p=0.0" where p is an Integer, then Axis2 will generate 500 HTTP Response and log an error in it's log saying something to the effect of:
[ERROR] Exception occurred while trying to invoke service method createUpdateOrganization
org.apache.axis2.AxisFault: Invalid value "0.0" for element poStart
...
This is great but I need to be able to capture this exception information in order to act upon it as part of our exception management framework.
It seems to be throwing an AxisFault exception but this is before it reaches my service so I'm not sure what I need to configure in order to get this information.
Any ideas?

I found the following article:
http://www.packtpub.com/article/handler-and-phase-in-apache-axis
Which explains exactly what I need to do. The answer is to create a custom handler for the InFaultFlow phase. :) I hope this helps somebody else!

Related

Which is a correct HTTP status code for "Error creating resource"?

I'm developing an application with authentication, and i need to provide a appropriate status code if there is any error when registering an user, for example a database-related error.
I've been researching but i haven't found an appropriate status code.
The purpose of all HTTP errors is to communicate the operation failed. To pick the right HTTP error, you need to know why it failed.
"database-related error" sounds like a server-side bug or problem, so this is likely just a 500.

OSB - Is there a way to generate default errors for internal errors?

I have a validate action in the OSB request pipeline which raises an error if the request is not according the schema.
In the error handler, I remove the header info and add some required header info before replying with a failure. However the response I get is the request body and not the fault which is in $fault. Is there a way to have OSB generate a standard soapFault using the $fault variable instead of having to manually create the error response body?
I'm having the same issue with the general error handler defined for the business service and the pipeline error handler when internal errors are raised.
Additionally, Is there a best-practice on how this is usually done for normal services and in case of passthrough services?
thanks

Mule CXF Web service error handling

This question is on Mule CXF error handling. I have a soap based web service basically this is a validation service that validates an incoming file and reports on any errors in the file. Once validation is unsuccessful i have a catch-exception-strategy which logs the error and sends a email to Prod support team. After validation is unsuccessful i need not call the subsequent steps in the flow. And only the logging and sending an email alert should happen. Shouldn't using a catch-exception-strategy solve the problem ( similar to a try/catch block in Java). But what i notice is the caller is sent a response back and subsequent flow steps are executed
In your catch exception strategy put an asynchronous flow and in that put your logger and smtp to send the mail ... I guess it will solve your problem ...
Since you will be using asynchronous flow response shouldn't be there ... Pls let me know if it solve your issue

How to get details exception from published Web Api

Is there any way to get detail exception & Stack trace from deployed Web Api?
Even if I deployed in Debug mode, do I get detail error traces?
I got bellow message from server API
"message": "Processing of the HTTP request resulted in an exception.
Please see the HTTP response returned by the 'Response' property of
this exception for details."
This happened only in server, same code running perfectly in local machine.
Did you check the content-type for the request that you are performing?
Sometimes this error comes because you don't specify this value, e.g. "application/json" in the headers of the request.
If your scenario is to have a central place to log any exceptions that happen when requests are being processed, then I would suggest to take a look at 5.1 version of Web API (released couple of days back), specifically the Global Error Handling feature.
http://www.asp.net/web-api/overview/releases/whats-new-in-aspnet-web-api-21#global-error
If you go to the above page,you should notice ExceptionLoggerContext which gives you details of the exception.
About Web API versions 5.0 and before:
In these versions there was no really a central place for catching exceptions. ExceptionFilterAttributes caught exceptions for only certain areas of Web API.

Savon and SoapUI

I always use SoapUI before moving on with Savon to see if my URL is correct. Now this time I was given a URL that (probably from a project developed and hosted on a Windows machine), let's say it is this one:
www.myservice.com/login/eeu.aspx?WSDL
Now when I try this, I get this:
Error loading [www.myservice.com/login/eeu.aspx?WSDL]: org.apache.xmlbeans.XmlException: org.apache.xmlbeans.XmlException: error: Unexpected character encountered (lex state 3): '&'
SoapUI will also do HTTP requests right? not only SOAP (or am I confusing something here?)
Why do I get this error?
The problem is not with HTTP request (although SoapUI really performs it to get WSDL file in your case). Error message says that there is problem with parsing of the response -- it is not a well-formed XML document. Download WSDL of your service manually and check it with XML Validator. If it shows that XML is correct then it still may be related to some temporary problem (connections limit, resources shortage) that leads an ASP-based service to reply with error page that doesn't pass validation when this problem occurs.