Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 664107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:33:48+00:00 2026-05-13T23:33:48+00:00

I have to connect to a poorly implemented server that only understands Content-Type (capital-T)

  • 0

I have to connect to a poorly implemented server that only understands Content-Type (capital-T) and not Content-type. How can I ask my JAX-WS client to send Content-Type?

I’ve tried:

Map<String, List<String>> headers = (Map<String, List<String>>)
((BindingProvider)port).getRequestContext().get(MessageContext.HTTP_REQUEST_HEADERS);

But headers is null. What am I doing wrong?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:33:48+00:00Added an answer on May 13, 2026 at 11:33 pm

    I have to connect to a poorly implemented server that only understands Content-Type(capital-T) and not Content-type. How can I ask my jax-ws client to send Content-Type?

    I’ve dug this question a bit more and, sadly, I’m afraid the answer is: you can’t. Let me share my findings.

    First, the code that you’ll find in https://jax-ws.dev.java.net/guide/HTTP_headers.html does not give you access to the HTTP headers of the future HTTP request (that hasn’t been created at this point), it allows you to set additional HTTP headers for making a request (that will be added to the HTTP request later).

    So, don’t expect the following code to not return null if you don’t put anything before (and actually, you’ll only get what you put in there):

    ((BindingProvider)port).getRequestContext().get(MessageContext.HTTP_REQUEST_HEADERS);
    

    Then, I did a little test based on the code provided in the same link:

    AddNumbersImplService service = new AddNumbersImplService();
    AddNumbersImpl port = service.getAddNumbersImplPort();
    
    ((BindingProvider)port).getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS,
        Collections.singletonMap("X-Client-Version",Collections.singletonList("1.0-RC")));
    
    port.addNumbers(3, 5);
    

    And this is what I see in the HTTP request when running the client code:

    POST /q2372336/addnumbers HTTP/1.1
    Content-type: text/xml;charset="utf-8"
    X-client-version: 1.0-RC
    Soapaction: ""
    Accept: text/xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    User-Agent: JAX-WS RI 2.1.6 in JDK 6
    Host: localhost:8080
    Connection: keep-alive
    Content-Length: 249
    

    Do you notice the difference: only the first char of the X-Client-Version header is kept upper cased, the rest is lowered!

    And indeed, if you check the class c.s.x.w.t.Headers that is used to represent HTTP request (and response) headers, you’ll see that it “normalizes” keys when they are added (in normalize(String)):

    /* Normalize the key by converting to following form.
     * First char upper case, rest lower case.
     * key is presumed to be ASCII 
     */
     private String normalize (String key) {
         ...
     }
    

    So, while the c.s.x.w.t.h.c.HttpTransportPipe class (my understanding is that this is where the HTTP request is created, this is also where previously added headers will be added to the HTTP request headers) actually adds "Content-Type" as key in a c.s.x.w.t.Headers instance, the key will be modified because of the previously mentioned implementation detail.

    I may be wrong but I don’t see how this could be changed without patching the code. And the odd part is that I don’t think that this “normalizing” stuff is really RFCs compliant (didn’t check what RFCs say about headers case though). I’m surprised. Actually, you should raise an issue.

    So I see three options here (since waiting for a fix might not be an option):

    • Patch the code yourself and rebuild JAX-WS RI (with all the drawbacks of this approach).
    • Try another JAX-WS implementation like CFX for your client.
    • Let the request go through some kind of custom proxy to modify the header on the fly.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't figure out why this is. I have a connect method that works
I have to connect with 3 diferent databases. How can i do that? I'm
I have multiple unit tests that have to connect to a MySQL Server to
I have implemented Facebook Connect into a HTML page exactly as the tutorial explains
I have to connect my app with server using either wifi (if it is
I'm doing an app that will have to connect to several hosts. Originally I
I have to connect in .NET to a service which can be accesed with
I have to connect to a third party web service that provides no wsdl
update: I have connect my provider and it turns out that servers are blocked
I have openVPN Connect configured on a vista laptop, so that connecting with a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.