Windows azure でホストされている wcf json サービスに https (トランスポート セキュリティを使用した webHttpBinding) で接続したいと考えています。アドレスは some_subdomain.somesite.com で、もちろん someapp.cloudapp.net にリダイレクトされます。ホスト名に「_」が含まれているため、「some_subdomain.somesite.com」は使用できません。
元のコード
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(serviceUrl + "/" + serviceMethod);
post.setHeader("Accept", "application/json");
post.setHeader("Content-type", "application/json");
String jsonParameters = gson.toJson(parameters);
post.setEntity(new StringEntity(jsonParameters));
HttpResponse response = client.execute(post);
HttpEntity entity = response.getEntity(); // throws here
return convertStreamToString(entity);
java.lang.IllegalArgumentException をスローします: ホスト名は null ではない可能性があります。
この類似のコード:
InputStream inputStream;
URL url = new URL(serviceUrl + "/" + serviceMethod);
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
httpConn.setRequestMethod("GET");
httpConn.connect(); // throws exception here
if(httpConn.getResponseCode() == HttpURLConnection.HTTP_OK)
{
inputStream = httpConn.getInputStream();
...
}
NullPointerException をスローします。
IPを入力するだけで、取得できます
javax.net.ssl.SSLException: 証明書のホスト名が一致しませんでした: IP_ADDRESS != some_subdomain.somesite.com
私は実稼働証明書を使用しているため、ドメインを変更して別の証明書を取得することはできません。すべてが iOS および WinRT バージョンで正常に動作することに注意してください。java のみがホスト名に問題があるようです。
では、どうすれば次のことができますか: a) ホスト名に「_」を含む URL を使用するか、b) サーバーの予想される ID を構成しますか?