Spring Webまたはその他のSpringツールを使用して、投稿データでhttps投稿リクエストを送信する方法を理解しようとしています。
これまで httpclient を使用してきましたが、Spring に変換しようとしています :)
https ポスト リクエストは、自己署名証明書を無視する必要があります。
それを行う方法の例を提供してください。
ありがとうございました
Spring Integration を使用して http POST と GET を送信します http://static.springsource.org/spring-integration/reference/html/http.html リクエスト ファクトリ Bean は、自己署名証明書を許可するように構成する必要があります。次の配線を使用して、http Spring Integration エンドポイントで使用されるapacheHttpsRequestFactoryを宣言します。
httpClient Bean を他のSpring Bean に注入して、http リクエストの送信に使用できます。
@Autowired
private HttpClient httpClient;
spring-interefration-context.xml のフラグメントは次のとおりです。
<!-- 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" />