views:

368

answers:

1

I am trying to consume the Exchange 2010 Web Service interface using JAX-WS. I'm using JAX-WS 2.2 RI (Metro 2.0). 2.1 exhibited the same problem.

I am running into trouble with Exchange, which returns "HTTP/1.1 415 Cannot process the message because the content type 'text/xml;charset=utf-8' was not the expected type 'text/xml; charset=utf-8'." as a reponse (2.1 quoted the charset value, otherwise same response).

Apparently I need to dictate the exact Content-type header for Exchange to be happy.

Is there a way for me to do this without forcing me to manually rebuild the dependency? I currently rely on published maven artifacts, and would like to continue doing this if at all possible.

The consuming process is a regular J2SE app, with no containers in sight. I have control of the application and can add pretty much anything required to the applications scope, but can not add out-of-process items like proxy servers. The client classes were generated from local WSDL, but the charset specification is derived from constants declared in the jaxws RI implementation, not the generated code. The resulting HTTP transport is thus handled by the standard http/https client from Sun JRE5 or JRE6.

A: 

From this thread (giving a cached link, because currently java.net forums are down), it appears that the fault is ultimately that your Exchange Web Service 2010 demands a space after the semicolon - something NOT part of the w3c spec.

A solution might be to put something (depending on your setup) in front of the metro to change the header.

You could try some of the following approaches:

  • Use reflection to change the Metro constant.
  • Use AOP (I can't tell you how exactly)
  • See where is this constant defined in Metro, create a package javax.xml.ws.etc (or com.sun.etc.. in your sources, and copy-paste the source for that class, changing the constant.
Bozho
Yes, I am aware of the space being the issue, hence why I am looking for a way to control the content-type header. Nice catch on the forum post, I had missed that one among the bulk of people with mime-type mismatches.
Johan Karlberg