Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-8062

MessageContext.HTTP_RESPONSE_CODE cannot be obtained if response code is not 4xx



    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.3.2
    • Fix Version/s: 3.2.10, 3.3.3
    • Component/s: None
    • Labels:
    • Estimated Complexity:


      After a web service request, we do this:

      responseCode = (Integer) ((BindingProvider) webServicePort).getResponseContext().get(MessageContext.HTTP_RESPONSE_CODE);

      , to extract the Http response code, but we noticed that this only works in our case with 200 response codes from the server.

      From what I could gather, it seems that the response context is not populated in cases where a 200 is not given. Example:

       As you can see only two instances of SCOPES are in the response context. When we receive a 200 from the web service, the response context contains this:

      , which although you can't see it in the screenshot, it contains the HTTP_RESPONSE_CODE value, which it's the only thing we need, because we need to do some additional steps depending on that response code afterwards.

      Right now, we're using a finicky way to obtain such http response code... the exception is a WebServiceException which contains a HTTPException which has the response code given by the server. We'd like to have a more reliable way since those exception signatures could just change over time if we update libraries / java versions we guess.

      Here's the CXF dependencies in our project:

      Let us know if you need to know about anything else. 


        1. 200.png
          53 kB
          Tomás García
        2. 401.PNG
          11 kB
          Tomás García
        3. cxf_dependencies.PNG
          19 kB
          Tomás García
        4. cxfresponsecode.zip
          24 kB
          Tomás García



            • Assignee:
              ffang Freeman Yue Fang
              tomasedata Tomás García
            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created: