我在 IBM Watson Studio 中創建了一個 ML 模型,并將該模型部署到 Web 服務中。我需要創建一個 java 程序來發送輸入并從該 Web 服務檢索輸出。我檢查了我所有的連接憑據,這沒有問題。我在這里使用的代碼與 watson-studio 中給出的代碼(在部署部分下的實現選項卡中)相同,但我仍然遇到錯誤。程序停在這一行scoringBuffer = new BufferedReader(new InputStreamReader(scoringConnection.getInputStream()));檢查此代碼:-package Original;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.io.OutputStreamWriter;import java.net.HttpURLConnection;import java.net.URL;import java.nio.charset.StandardCharsets;import java.util.Base64;import java.util.HashMap;import java.util.Map;public class Iris_Deployment { public static void main(String[] args) { // NOTE: you must manually construct wml_credentials hash map below // using information retrieved from your IBM Cloud Watson Machine Learning Service instance. Map<String, String> wml_credentials = new HashMap<String, String>() {{ put("url", "https://eu-gb.ml.cloud.ibm.com"); put("username", "my-username-comes-here"); put("password", "my-password-comes-here"); }}; String wml_auth_header = "Basic " + Base64.getEncoder().encodeToString((wml_credentials.get("username") + ":" + wml_credentials.get("password")).getBytes(StandardCharsets.UTF_8)); String wml_url = wml_credentials.get("url") + "/v3/identity/token"; HttpURLConnection tokenConnection = null; HttpURLConnection scoringConnection = null; BufferedReader tokenBuffer = null; BufferedReader scoringBuffer = null;
添加回答
舉報
0/150
提交
取消