I'm using a JAX-WS generated client (using wsimport, the one bundled with Glassfish 2.1.1) to connect to a ASP.NET generated WebService running in a IIS 6.
When I request compression in the response (by including HTTP Header Accept-Encoding: gzip through JAX-WS SOAP Handlers) the IIS 6 answers with a compressed response, but doesn't includes the Content-Encoding: gzip HTTP response header, so i get the following Exception:
com.sun.xml.ws.protocol.soap.MessageCreationException: Couldn't create SOAP message due to exception: XML reader error: com.sun.xml.stream.XMLStreamException2: ParseError at [row,col]:[1,1]
Message: Content is not allowed in prolog.
at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:361) at com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:173)
at com.sun.xml.xwss.XWSSClientPipe.process(XWSSClientPipe.java:160)
at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:115)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:595)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:554)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:539)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:436)
at com.sun.xml.ws.client.Stub.process(Stub.java:248)
at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:135)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:109)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)
Edited Apr 17, 2011
I've also tried, using the same SOAPHandler I use for requesting compressed response, to modify the Response Headers, but the Exception occurs before the Handler is called.
End Edit Apr 17, 2011
Also, when I make the same request to the WebService through soapUI 3.6.1 with the Preference "Accept compressed responses from hosts", I can see what I've said: the IIS 6 server is not including the HTTP Response Header for compression, and soapUI shows the response as "binary data" and shows these response headers:
HTTP/1.1 200 OK
Date: Wed, 13 Apr 2011 08:50:55 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Content-Length: 1104
If -with soapUI- I don't request compressed response I get the next response size:
Content-Length: 2665
So, the question here is, as I've said, that IIS6 is not adding the Contend-Encoding header in the response. My question is: Is it possible to -programmatically- add the Content-Encoding header? Or, it also could be: Is it possible to ask IIS6 to include the Content-Encoding header?
UPDATE
Using Charles Web Debugging Proxy 3.5.2 I've confirmed the response from IIS6 doesn't include the Content-Encoding header:
HTTP/1.1 200 OK
Date Wed, 13 Apr 2011 10:51:53 GMT
Server Microsoft-IIS/6.0
X-Powered-By ASP.NET
X-AspNet-Version 2.0.50727
Cache-Control private, max-age=0
Content-Type text/xml; charset=utf-8
Content-Length 1110
I'm guessing this may be an issue more related to the WebService than to IIS 6
Simple Way to Get HTTP Response Header in Java – conn. getHeaderFields() public Map<String,List<String>> getHeaderFields() Returns an unmodifiable Map of the header fields. The Map keys are Strings that represent the response-header field names.
Open the site which you would like to open and then click on the HTTP Response Headers option. Click on the X-Powered-By header and then click Remove on the Actions Pane to remove it from the response.
A response header is an HTTP header that can be used in an HTTP response and that doesn't relate to the content of the message. Response headers, like Age , Location or Server are used to give a more detailed context of the response.
Basically you need two components. First you must create a filter and add it in web.xml as this:
<filter>
<filter-name>yourFilter</filter-name>
<filter-class>yourFilterClassWhichAddsTheCorrectHeader</filter-class>
</filter>
<filter-mapping>
<filter-name>yourFilter</filter-name>
<url-pattern>theServletUrlMappedToJaxWS</url-pattern>
</filter-mapping>
Next you might need to create a wrapper of the response where you add the missing header.
Actually you might get not need the wrapper at all, just set the missing header directly in the filter you configured in web.xml
Hope this helps...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With