Problem using Exchange Web Service 2010 using jax-ws metro

I am trying to use the Exchange 2010 web service interface using JAX-WS. I am using JAX-WS 2.2 RI (Metro 2.0). 2.1 the same problem appeared.

I'm having problems with Exchange, which returns "HTTP / 1.1 415 Cannot process the message because the content type is" text / xml; charset = utf-8 "was not the expected type" text / xml; charset = utf -8 '". as the answer (2.1 quotes the encoding value, otherwise the same answer).

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

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

The consumption process is a regular J2SE application, with no visible containers. I control the application and can add almost everything that is required for the application area, but I can not add elements outside the process, such as proxies. Client classes were created from the local WSDL, but the charset specification is derived from the constants declared in the RI jaxws implementation, not the generated code. Thus, the received HTTP transport is processed by the standard http / https client from Sun JRE5 or JRE6.

+1
source share
1 answer

From this thread (giving the link in the cache because java.net is currently not working on the forums), it seems that the error is ultimately such that your Exchange 2010 web service requires space after the semicolon - something NOT is part of the w3c specification.

The solution may be to put something (depending on your setting) in front of the metro to change the heading.

You can try some of the following approaches:

  • Use reflection to change the Metro constant.
  • Use AOP (I can’t say exactly how)
  • Look where this constant is defined in Metro, create the javax.xml.ws.etc package (or com.sun.etc.. ) in your sources and copy the source for this class by changing the constant.
+1
source

Source: https://habr.com/ru/post/1393576/


All Articles