我有一个 Tomcat 服务器在 Apache 2“后面”运行(通过 mod_proxy),在 Tomcat 中有一个 WAR 服务于 Spring 生成的 Web 服务,它公开了这样一个服务:
<wsdl:service name="EcoboxPortService">
<wsdl:port binding="tns:EcoboxPortSoap11" name="EcoboxPortSoap11">
<soap:address location="http://host:80/ecobox-ws/Ecobox"/>
</wsdl:port>
</wsdl:service>
问题是WSDL实际上是通过以下URL获取的:
https://host/ecobox-ws/ecobox.wsdl (Please note it uses HTTPS)
鉴于以上2个问题出现:
- 为什么 WSDL 将“80”端口添加到端点位置?它可以被覆盖吗?
- 尽管请求的实际 URL 是通过“https”获取的,但为什么它会获得“http”协议(protocol)? Spring 不解释“X-forwarded-for” header 吗?
类似的问题,但不是完全有用:change the soap:address location in generated wsdl
相关依赖:
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>2.2.2.RELEASE</version>
</dependency>
相关的 web.xml 摘录:
<servlet>
<servlet-name>spring-ws</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<init-param>
<param-name>transformWsdlLocations</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
最佳答案
看看here
您需要告诉 MessageDispatherServlet 转换位置:
<servlet>
<servlet-name>spring-ws</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<init-param>
<param-name>transformWsdlLocations</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
或者如果你使用 Java Config
If you use the AbstractAnnotationConfigMessageDispatcherServletInitializer, enabling transformation is as simple as overriding the isTransformWsdlLocations() method to return true.
关于java - Spring 生成的 WSDL 公开了错误的协议(protocol)(HTTP 与 HTTPS)端点位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42391488/