2013-12-20 6 views
1

https webservice와의 통신 중 오류가 발생했습니다. 나는 아래 봄의 WebServiceTemplate를 사용하고SSLHandshakeException이 Spring WebServiceTemplate을 사용하여 https 웹 서비스와 통신합니다.

org.springframework.ws.client.WebServiceIOException: I/O error: 
sun.security.validator.ValidatorException: PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid 
certification path to requested target; nested exception is 
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX 
path 
building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to 
find valid certification path to requested target 

내가 쓴 샘플 자바 코드에서 soapui에서가 아닌 서비스를 칠 수 있어요 그것을

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xmlns:p="http://www.springframework.org/schema/p" 
xmlns:sws="http://www.springframework.org/schema/web-services" 
xmlns:oxm="http://www.springframework.org/schema/oxm" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
     http://www.springframework.org/schema/web-services 
     http://www.springframework.org/schema/web-services/web-services-2.0.xsd 
     http://www.springframework.org/schema/oxm 
     http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd"> 

<bean id="webServiceTemplate" 
class="org.springframework.ws.client.core.WebServiceTemplate" 
p:marshaller-ref="jaxbMarshaller" 
p:unmarshaller-ref="jaxbMarshaller" 
p:defaultUri="https://XXXXXXXXXXXXXXXX" 
p:messageSender-ref="messageSender"> 
<constructor-arg ref="messageFactory" /> 
</bean> 

<bean id="messageSender" 
class="org.springframework.ws.transport.http.CommonsHttpMessageSender" /> 

<!-- <bean id="messageSender" 
class="org.springframework.ws.transport.http.HttpsUrlConnectionMessageSender" /> --> 

<bean id="messageFactory" 
class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" /> 

<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller" 
p:contextPath="com.test.schemas" /> 

</beans> 

내 XML 구성입니다. 어떤 사람이 왜 이런 일이 일어나고 있는지 그리고 어떻게 해결할 수 있는지를 알려 주실 수 있습니까? 우리는 3thrd party wsdl 사람들로부터 보안 인증서를 받아야합니까?

+0

업데이트 -이 기사에 따라 서버의 인증서를 (점점 시도 - http://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to- find-valid-certification-path-to-requested-target /) 및 jdk 트러스트 스토어에 추가하지만 지금 아래 오류가 발생합니다 - org.springframework.ws.client.WebServiceTransportException : Precondition Failed [412] – user3097172

+0

can anyone PLZ 도움? – user3097172

답변

0

설명서에 따르면 CommonsHttpMessageSender는 HttpComponentsMessageSender를 사용하여 더 이상 사용되지 않습니다. HttpComponentsMessageSender의

세션 객체를 구성하십시오 부동산 : http://docs.spring.io/spring-ws/site/apidocs/org/springframework/ws/transport/http/HttpComponentsMessageSender.html#setHttpClient%28org.apache.http.client.HttpClient%29

자체 서명 인증서 문제를 해결하기 위해 세션 객체 콩을 구성하는 방법에 대한 내 다른 게시물을 참조하십시오. sending https post request with post data using spring web

키 저장소로 키를 가져올 필요가 없습니다.

+0

borodark, 샘플 코드를 제공해 주시겠습니까? – Defuera

+2

위의 xml 참조 - 아이디어는 httpClient를 삽입하는 것입니다. borodark

0

확인이 작동하는지 :

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xmlns:p="http://www.springframework.org/schema/p" 
xmlns:sws="http://www.springframework.org/schema/web-services" 
xmlns:oxm="http://www.springframework.org/schema/oxm" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
     http://www.springframework.org/schema/web-services 
     http://www.springframework.org/schema/web-services/web-services-2.0.xsd 
     http://www.springframework.org/schema/oxm 
     http://www.springframework.org/schema/oxm/spring-oxm-1.5.xsd"> 


<!-- HTTPS connection to trust self signed certificates --> 
<bean id="sslSocketFactory" class="org.apache.http.conn.ssl.SSLSocketFactory"> 
    <constructor-arg name="trustStrategy"> 
     <bean class="org.apache.http.conn.ssl.TrustSelfSignedStrategy" /> 
    </constructor-arg> 
    <constructor-arg name="hostnameVerifier"> 
     <bean class="org.apache.http.conn.ssl.AllowAllHostnameVerifier" /> 
    </constructor-arg> 
</bean> 

<bean id="httpsSchemaRegistry" class="org.apache.http.conn.scheme.SchemeRegistry"> 
    <property name="items"> 
     <map> 
      <entry key="https"> 
       <bean class="org.apache.http.conn.scheme.Scheme"> 

        <constructor-arg value="https" /> 
        <constructor-arg value="443" /> 
        <constructor-arg ref="sslSocketFactory" /> 
       </bean> 
      </entry> 
     </map> 
    </property> 
</bean> 
<bean id="httpClient" class="org.apache.http.impl.client.DefaultHttpClient"> 
    <constructor-arg> 
     <bean class="org.apache.http.impl.conn.PoolingClientConnectionManager"> 
      <constructor-arg ref="httpsSchemaRegistry" /> 
     </bean> 
    </constructor-arg> 
</bean> 

<!-- <bean id="apacheHttpsRequestFactory" 
    class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory"> 
    <constructor-arg ref="httpClient" /> 
--> 
<bean id="webServiceTemplate" 
class="org.springframework.ws.client.core.WebServiceTemplate" 
p:marshaller-ref="jaxbMarshaller" 
p:unmarshaller-ref="jaxbMarshaller" 
p:defaultUri="https://XXXXXXXXXXXXXXXX" 
p:messageSender-ref="messageSender"> 
<constructor-arg ref="messageFactory" /> 
</bean> 

<bean id="messageSender" 
class="org.springframework.ws.transport.http.HttpComponentsMessageSender" 
p:httpClient="httpClient" /> 


<bean id="messageFactory" 
class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory" /> 

<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller" 
p:contextPath="com.test.schemas" /> 


</beans>