0
sharepointへの接続を試みるときにHTTP/1.1 302 Found
というメッセージが表示されます。メッセージ302 sharepointに接続中に見つかりました
私はthisコードをmirontoliで作成し、nddipiazzaで修正しています。
また、URLConnectionにプロキシを追加しました。
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)); // added //
URLConnection uc = u.openConnection(proxy); // modified //
extractToken()
のメソッドが空のStringを返すため、原因と考えられます。
extractToken()コード:ここから呼び出され
private String extractToken(String result)
throws SAXException, IOException, ParserConfigurationException, XPathExpressionException {
// http://stackoverflow.com/questions/773012/getting-xml-node-text-value-with-java-dom
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(new InputSource(new StringReader(result)));
XPathFactory xpf = XPathFactory.newInstance();
XPath xp = xpf.newXPath();
String token = xp.evaluate("//BinarySecurityToken/text()", document.getDocumentElement());
// handle error S:Fault:
// http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/df862099-d9a1-40a4-b92e-a107af5d4ca2
System.out.println(token);
return token;
}
:
private String requestToken()
throws XPathExpressionException, SAXException, ParserConfigurationException, IOException {
String saml = generateSAML();
URL u = new URL(sts);
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));// added//
URLConnection uc = u.openConnection(proxy);// modified//
HttpURLConnection connection = (HttpURLConnection) uc;
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestMethod("POST");
// http://stackoverflow.com/questions/12294274/mobile-app-for-sharepoint/12295224#12295224
// connection.addRequestProperty("SOAPAction", sts);
connection.addRequestProperty("Content-Type", "text/xml; charset=utf-8");
// connection.addRequestProperty("Expect", "100-continue");
// connection.addRequestProperty("Connection", "Keep-Alive");
// connection.addRequestProperty("Content-Length", saml.length() +
// "");
// connection.setRequestProperty("SOAPAction", SOAP_ACTION);
OutputStream out = connection.getOutputStream();
Writer wout = new OutputStreamWriter(out);
wout.write(saml);
wout.flush();
wout.close();
InputStream in = connection.getInputStream();
int c;
StringBuilder sb = new StringBuilder("");
while ((c = in.read()) != -1)
sb.append((char) (c));
in.close();
String result = sb.toString();
String token = extractToken(result);
System.out.println(token);
return token;
}
私は、httpは私が求めている理由がある作品正確にどのように知りません。
どのような問題がありますか?
ありがとうございました。