2

このページから情報を取得するためにBlazeDSJavaクライアントを使用しています。このページの中央には、タイプを選択するとボタンの位置コンボが更新されるフォームがあります。

私はBlazeDSを使用してJavaでこれらの値を取得しようとしています。私はCharlesWebプロキシを使用してデバッグしてきましたが、これはリクエストレスポンスのスクリーンショットです。

これまでの私のコードは次のとおりです。

        // Create the AMF connection.
        AMFConnection amfConnection = new AMFConnection();

        // Connect to the remote url.
        String url = "http://orlandoinfo.com/flex2gateway/";
        try
        {
            amfConnection.connect(url);
        }
        catch (ClientStatusException cse)
        {
            System.out.println(cse);
            return;
        }

        // Make a remoting call and retrieve the result.
        try
        {
//          amfConnection.registerAlias("flex.messaging.io.ArrayCollection", "flex.messaging.io.ArrayCollection");
            amfConnection.call("ColdFusion.getLocations", new Object[] {"consumer", "attractions", "ATTR"});

        }

        catch (ClientStatusException cse)
        {
            System.out.println(cse);
        }
        catch (ServerStatusException sse)
        {
            System.out.println(sse);
        }

        // Close the connection.
        amfConnection.close();

実行すると、次のようになります。

ServerStatusException 
    data: ASObject(15401342){message=Unable to find source to invoke, rootCause=null, details=null, code=Server.Processing}
    HttpResponseInfo: HttpResponseInfo 
    code: 200
    message: OK

誰かが何が悪いのかを見つけることができますか?

読んでくれてありがとう!

4

1 に答える 1

4

私はCharlesWebProxyを使用することになりました。AMFパラメータをスニッフィングし、コードを実行する-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8888

私は両方の呼び出しを比較し、似ているように変更します。動作するコードは次のようになります。

String url = "http://www.theGateWayurl.com";
// Generates the connection to the amf gateway.
AMFConnection amfConnection = new AMFConnection();

// Must register the class that this library will use to load the
// AMF object information.
// The library will read AMF object variables and use setters from
// the java bean stated in this line.
AMFConnection.registerAlias("", new LabelData().getClass().getName());

try {
    // Do the connection.
    amfConnection.connect(url);

    // This page requires a certain headers to function.
    // The Content-type is used to sniff with Charles Web Proxy.
    amfConnection.addHttpRequestHeader("Content-type", "application/x-amf");
    // The Referer is used by the webpage to allow gathering information.
    amfConnection.addHttpRequestHeader("Referer", "http://orlandoinfo.com/ws/b2c/sitesearch/customtags/comSearch.swf");

    // The rest of the HTTP POST sent by this library is wrapped
    // inside a RemotingMessage.
    // Prepare the msg to send.
    RemotingMessage msg = new RemotingMessage();

    // The method called in the server.
    msg.setOperation("getLocations");

    // Where the request came from. Similar to referer.
    msg.setSource("ws.b2c.sitesearch.components.myService");

    // The destination is a needed parameter.
    msg.setDestination("ColdFusion");

    // Create the body with the parameters needed to call the
    // operation set with setOperation()
    msg.setBody(new Object[] {"consumer", "attractions"});

    // This is needed but not used.
    msg.setMessageId("xxxxxxxxxx");

    // Send the msg.
    AcknowledgeMessage reply = (AcknowledgeMessage) amfConnection.call("null", msg);

    // Parse the reply from the server.
    ArrayCollection body = (ArrayCollection) reply.getBody();
    for (Object obj : body) {
        LabelData location = (LabelData) obj;
        // Do something with the info.
    }

} catch (ClientStatusException cse) {
    // Do something with the exception.

} catch (ServerStatusException sse) {
    // Do something with the exception.
} finally {
    amfConnection.close();
}

LabelDataは、DataとLabelの2つの変数を持つ単なるJavaBeanです。理解を深めるために、すべての行にコメントを付けようとしました。Stuがcrossdomain.xmlに関する以前のコメントで言及したことを考慮に入れて、この種のことを行う権利があるかどうかを確認してください。

于 2009-11-16T19:59:48.070 に答える