質問

J2ME(いくつかのライブラリまたは手動コーディング)でWebDAVを使用する方法はありますか?

私が試してみた:
を - javax.microedition.io.HttpConnection 、しかし
方法がサポートされていない「SEARCH」 - javax.microedition.io.SocketConnection のHttp要求すると - 何も戻ります応答で
たぶん、私のコードまたはHTTPヘッダに何かます:

    String response = "";
    String query = "<?xml version='1.0'?> " 
            + "<g:searchrequest xmlns:g='DAV:'> "
            + "<g:sql> "
            + "SELECT 'DAV:displayname' "
            + "FROM 'http://exchangeserver.com/Public/' "
            + "</g:sql> "
            + "</g:searchrequest> ";
    String len = String.valueOf(query.length());
    SocketConnection hc = (SocketConnection) Connector
            .open("socket://exchangeserver.com:8080");
    DataOutputStream dout = 
            new DataOutputStream(hc.openOutputStream());
    DataInputStream din = new DataInputStream(hc.openInputStream());
    String userPass = "username" + ":" + "password";
    byte[] encoded = 
            Base64OutputStream.encode(userPass.getBytes(), 0,
            userPass.length(), false, false);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    String request = "SEARCH /Public/ HTTP/1.1\r\n"
            +"Content-Type:text/xml\r\nContent-Length:"
            + len
            + "\r\nAuthorization:Basic "
            + new String(encoded)
            + "\r\n\r\n";
    bos.write(request.getBytes());
    bos.write(query.getBytes());
    dout.write(bos.toByteArray());
    dout.flush();
    dout.close();
    byte[] bs = new byte[900];
    din.readFully(bs);
    bos = new ByteArrayOutputStream();
    bos.write(bs);
    din.close();
    hc.close();
    response = bos.toString();
役に立ちましたか?

解決 2

[ホストプロパティのために正しかった1ジュリアン、QRSO +1、すべてに感謝! だから、
- 私は自由のWebDAVサービスを発見した MyDisk.se の(検索が許可されていないので、私が使用しPROPFIND)
- WFetchではのに使用WebDAVの要求で遊ん
- 使用ネットワークモニタする WFetchでは、私のアプリからの要求を比較する。
:)最後に、それが働いています! 結果コード:

String response = "";
String query = "<?xml version='1.0' encoding='UTF-8'?>\r\n"
        + "<d:propfind xmlns:d='DAV:'>\r\n"
        + "<d:prop><d:getcontenttype/></d:prop>\r\n"
        + "<d:prop><d:getcontentlength/></d:prop>\r\n"
        + "</d:propfind>\r\n";

String len = String.valueOf(query.length());
SocketConnection hc = (SocketConnection) Connector
        .open("socket://79.99.7.153:80");
DataOutputStream dout = new DataOutputStream(hc.openOutputStream());
DataInputStream din = new DataInputStream(hc.openInputStream());
String userPass = "login" + ":" + "password";
byte[] encoded = Base64OutputStream.encode(userPass.getBytes(), 0,
        userPass.length(), false, false);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
String request = "PROPFIND /mgontar/ HTTP/1.1\r\n" 
        + "Depth: 1\r\n"
        + "Host: mydisk.se:80\r\n" 
        + "Accept: */*\r\n"
        + "Content-Type: text/xml\r\n" 
        + "Content-Length: " + len
        + "\r\nAuthorization: Basic " + new String(encoded)
        + "\r\n\r\n";
bos.write(request.getBytes());
bos.write(query.getBytes());
dout.write(bos.toByteArray());
dout.flush();
dout.close();
byte[] bs = new byte[900];
din.readFully(bs);
bos = new ByteArrayOutputStream();
bos.write(bs);
din.close();
hc.close();
response = bos.toString();

他のヒント

あなたは「何もリターン」とはどういう意味ですか?いいえレスポンスボディませんか?ノーステータスコード?

私は「ワイヤ」に何が起こっているのか追跡することをお勧めします...

UPDATE:?あなたがホストヘッダーを追加しようとしている。

あなたは、実際の携帯電話でテストしているFYI場合は、お使いのモバイルネットワークオペレータは非HTTPトラフィックをブロックすることができ公正なチャンスがあります。

あなたが最初にあなたが最初のサーバーにGETとPOSTリクエストを作ることができることを確認したい場合があります。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top