3

Colleagues,

I have SOAP web-service based on CXF implementation with enabled SSL & WSS configuration (cofigured using WSP). I have test tool for testing this service also written using CXF.

Positive cases are working. Trying to test negative cases with security errors (wrong certificate / signature).

I have requirement from customer that in case of security errors return fault:401 and HTTP response code 401.

Problem: When I return HTTP code 401 from web-service on receiver side (in test tool) I receive Marshaling errors because of incoming internal InputStream is empty (without content). When I return any other HTTP code (200/403/419/500/503) - there isn't any problem on receiver side! And I'm able to see SOAP fault with message generated in web-service side.

Questions:

  • Maybe there are some specific handling 401 HTTP code in CXF ?
  • Maybe there are some specific requirements in SOAP in general ?

If returning 401 HTTP code in SOAP it's bad practice could you please provide documents/source code to prove this behavior and help me change customer requirements. I tried to look throw the code and haven't find place where this case handles

P.S: Tried to capture traffic using WireShark and RawCap and tried to decode it without success.

damintsew
  • 88
  • 9
  • Are you confident that CXF is handling the authentication that leads to the 401? It may not be seeing the request if the authentication is being failed by the containing application server. To customize the 401 error as a SOAP response, you may need to first unsecure the web service URL in the web.xml (or equivalent), and then handle the authentication directly yourself (e.g. `HttpServletRequest.login()` ). – df778899 Sep 10 '18 at 18:25

2 Answers2

0

I think answer in this question will help you question

The question also includes a reference to the soap specification for your customers about fault response codes.

c0ld
  • 770
  • 4
  • 15
0

Be careful because there are some major differences between SOAP 1.1 and SOAP 1.2 in the allowed HTTP status codes when a SOAP fault is returned.

  • in SOAP 1.1, the status code must always be 500 “Internal Server Error”.
  • in SOAP 1.2, it varies based on the type of the SOAP fault
TacheDeChoco
  • 3,683
  • 1
  • 14
  • 17