2017-02-22 64 views
0

我有一個Tomcat服務器在Apache 2後面運行(通過mod_proxy),在Tomcat中有一個服務於Spring的Web服務的WAR服務,這一個:Spring生成的WSDL暴露了錯誤的協議(HTTP vs HTTPS)端點位置

<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個問題出現:

  1. 爲什麼WSDL將'80'端口添加到端點位置?它可以被覆蓋嗎?
  2. 爲什麼會得到'http'協議,儘管實際的URL請求是通過'https'? Spring不會翻譯'X-forwarded-for'頭文件嗎?

類似的問題,但完全沒有任何幫助: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> 
+0

是你的服務器(tomcat和或Apache)啓用HTTP服務資源?在我看來,更像tomcat的東西。您的Web應用程序能夠在HTTP中爲資源提供服務嗎? –

+0

@AngeloImmediata是的,實際上Tomcat只配置爲HTTP,但Apache配置爲 – gvasquez

+0

當您嘗試通過輸入URL http://來顯示WSDL時,您是否檢查過您是否在https中重定向?如果是這樣的話......這與Apache配置有關。你可以做的另一項檢查是直接訪問WSDL(可能是服務器上的wget) –

回答

1

你可能想檢查你的Tomcat配置,你需要設置「proxyName」和「proxyPort」。 JAX-WS自動生成應該從那裏/請求頭中選取它。 更多的信息在這裏:http://tomcat.apache.org/tomcat-6.0-doc/proxy-howto.html

+0

我喜歡這種方法,我會通過調整這些值來看看我得到了什麼,但乍一看我可以看到,我可以指導Tomcat公開端口443而不是80,但協議又如何呢?它仍然會報告http而不是https,對嗎? – gvasquez

+0

剛剛錯過了被強制轉換爲「https」的「模式」屬性,並在443中使用了proxyPort,並且做到了這一招...很好的答案! – gvasquez

+0

總是樂於幫忙,在不久之前使用nginx w/spring-boot也有類似的問題:) – bigZee77

2

看一看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配置

如果使用 AbstractAnnotationConfigMessageDispatcherServletInitializer,使 轉型是重寫 isTransformWsdlLocations一樣簡單( )方法返回true。

+0

它已經這樣配置了,至少它保留了「外部」主機名,而不是協議,也沒有端口。 – gvasquez