【发布时间】:2011-03-24 21:33:13
【问题描述】:
在通过 AJP/1.3 连接器访问托管在 Apache 后面的 Tomcat 中的 Axis2 Web 服务时,我遇到了 HTTP Response Content-Type 标头不正确的问题。
我可以通过其 RESTful 界面在浏览器中毫无问题地访问 Web 服务,我可以看到结果,但不知何故 Apache 正在将 Tomcat 发送的响应 Content-Type 标头从 text/xml 更改为 text/plain,它阻止了我由于Unsupported Content-Type: text/plain Supported ones are: [text/xml] 异常,无法通过 NetBeans 中的 SOAP 使用 Web 服务。
这是我的 Apache vhosts 配置的相关部分:
<VirtualHost *:80>
ServerAdmin me@myserver.example
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>
还有我的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" />
如果我使用端口 8080 上的默认连接器直接在 Tomcat 中访问 WS,我会得到正确的 content-type,但如果我通过 Apache 访问它,则会得到 text/plain,所以这肯定是代理的问题。
我该如何解决这个问题?
编辑:我使用 Tomcat HTTP 连接器进行代理而不是 AJP 连接器,但如果找到可行的解决方案,我更愿意使用 mod_ajp。
我刚换了
ProxyPass ajp://localhost:8009/axis2/services
ProxyPassReverse ajp://localhost:8009/axis2/services
行到
ProxyPass http://localhost:8080/axis2/services
ProxyPassReverse http://localhost:8080/axis2/services
【问题讨论】:
-
markmail.org/message/… 似乎与您的问题有关
-
是的,这是同一个问题,我已经找到了一些类似 2007 年的邮件存档,然后在这里发布问题,但我仍然找不到解决这个问题的方法。
标签: apache tomcat proxy content-type axis2