views:

96

answers:

0

I'm having a problem with an incorrect HTTP Response Content-Type header while accessing an Axis2 web service hosted in Tomcat behind Apache through an AJP/1.3 connector.

I can access the web service without problems in the browser through its RESTful interface and I can see the results but somehow Apache is changing the response Content-Type header sent by Tomcat from text/xml to text/plain and it prevents me from consuming the web service through SOAP in NetBeans, because of an Unsupported Content-Type: text/plain Supported ones are: [text/xml] exception.

Here's the relevant section of my Apache vhosts configuration:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName  myserver.example
    ServerAlias other.myserver.example

    ProxyPreserveHost On 
    SetEnv force-proxy-request-1.0 1
    SetEnv proxy-nokeepalive 1

    <Location /axis2/services>
        ProxyPass ajp://localhost:8009/axis2/services
        ProxyPassReverse ajp://localhost:8009/axis2/services
    </Location>
</VirtualHost>

And the relevant section of my Tomcat server.xml:

<Connector port="8009" protocol="AJP/1.3" redirectPort="9443" />

<Connector port="9443" protocol="HTTP/1.1" SSLEnabled="true" maxHttpHeaderSize="8192"
    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    enableLookups="false" disableUploadTimeout="true"
    acceptCount="100" scheme="https" secure="true"
    clientAuth="false" sslProtocol="TLS"
    SSLCertificateFile="path/to/bundle" 
    SSLCertificateKeyFile="path/to/key"
    SSLPassword="S3cr3t"
    proxyName="myserver.example" proxyPort="443" />

If I access the WS directly in Tomcat using the default connector on port 8080 I get the correct content-type but if I access it through Apache then I get text/plain, so it's definitely a problem with the proxy.

How can I solve this problem?

EDIT: I got it to work by using the Tomcat HTTP connector for the proxying, instead of the AJP one, but I would prefer to use mod_ajp if I find a working solution.

I just changed the

ProxyPass ajp://localhost:8009/axis2/services
ProxyPassReverse ajp://localhost:8009/axis2/services

lines to

ProxyPass http://localhost:8080/axis2/services
ProxyPassReverse http://localhost:8080/axis2/services