RE: Making amf calls from java instead of flash

"Jackson, Stephen" <[email protected]>
Newsgroups gmane.comp.java.openamf.user
Message-ID <3428D9627CC79A4ABF37A519431D98122F03BF@nmr001oldmsx05.enterprisenet.org>
It seems that if an exception happened and I read the stream it displays
the exception.  Great except how do you determine an error condition has
happened?  Otherwise I can't get to the actual results, the AMFObject is
always null.
 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Jackson,
Stephen
Sent: Wednesday, March 16, 2005 9:02 AM
To: [email protected]
Subject: RE: [Openamf-user] Making amf calls from java instead of flash

I was looking at AMFError but it looks like a simple pojo and I saw
nothing in AMFMessage to specifically grab an error condition.  Even
when I don't get an exception I still only get the following response.

INFO: Deserializing Message, for more info turn on debug level
[AMFMessage: {version=0, headers={}, bodies={[AMFBody:
{serviceName=null, serviceMethodName=null, response=null, type=OBJECT,
value=ASObject[type=null]}]}}]

I know there is something there because when I run it in flash it shows
up correctly.

I will try dumping to sysout.  The data has to be there because
inputstream.available() seems to fit the calls I am making.



-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of David
Jones
Sent: Wednesday, March 16, 2005 5:50 AM
To: [email protected]
Subject: RE: [Openamf-user] Making amf calls from java instead of flash

It's been a while since I was doing this but I seem to remember a
special error object (AMFError?) that you have to query for problems - I
think it contains the exception name.  Also, the code below may not
work, I notice that streams are not being flushed and closed.  Have you
tried dumping the contents of the http stream to sysout?

-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of Jackson,
Stephen
Sent: 15 March 2005 19:45
To: [email protected]
Subject: RE: [Openamf-user] Making amf calls from java instead of flash


I always get the same AMFMessage back, all values are null.  It looks
like the data is there because the inputStream size varies.  I know the
server is creating the response correctly but never get any data in the
AMFBody, all values in the map are null. 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Jackson,
Stephen
Sent: Tuesday, March 15, 2005 2:04 PM
To: [email protected]
Subject: RE: [Openamf-user] Making amf calls from java instead of flash

Is there anything special you have to do to read the error?  For some
reason exceptions are not showing up in the AMFMessage from the http
InputStream. 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of David
Jones
Sent: Tuesday, March 15, 2005 12:44 PM
To: [email protected]
Subject: RE: [Openamf-user] Making amf calls from java instead of flash

ASTranslator provides a Java interface to ASObjects, I've used these in
JUnit test cases to test my interface.

See
http://carbonfive.sourceforge.net/astranslator/api/com/carbonfive/flash/
package-summary.html#documentation

This might help you get started:

    protected AMFMessage sendRequest(String service, String method,
Object[] arguments)
    throws Exception {
        Object[] asArgs = new Object[arguments.length];
        ASTranslator translator =
ASTranslatorFactory.getInstance().getASTranslator();

        for(int i = 0; i < asArgs.length; i++) {
            asArgs[i] = translator.toActionScript(arguments[i]);
        }

        AMFBody body = new AMFBody(service + "." + method, "/1", asArgs,
AMFBody.DATA_TYPE_ARRAY);
        AMFMessage requestMessage = new AMFMessage();
        requestMessage.setVersion(0);
        requestMessage.addBody(body);

        ByteArrayOutputStream baOutputStream = new
ByteArrayOutputStream();
        DataOutputStream outputStream = new
DataOutputStream(baOutputStream);
        AMFSerializer serializer = new AMFSerializer(outputStream);
        serializer.serializeMessage(requestMessage);

        PostMethod post = new PostMethod("http://localhost/gateway");
        post.setRequestBody(new
ByteArrayInputStream(baOutputStream.toByteArray()));
        post.setRequestContentLength(baOutputStream.size());
        post.setRequestHeader("Content-type", "application/x-amf");

        int result = m_httpclient.executeMethod(post);

        DataInputStream inputStream = new DataInputStream(new
ByteArrayInputStream(post.getResponseBody()));

        AMFDeserializer deserializer = new AMFDeserializer(inputStream);
        AMFMessage toReturn = deserializer.getAMFMessage();
        post.releaseConnection();

        return toReturn;
    }

http://localhost/gateway is where my openAMF servlet is listening. I use
apache http client to send the messages.

HTH
Dave

-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of Jackson,
Stephen
Sent: 15 March 2005 14:01
To: [email protected]
Subject: [Openamf-user] Making amf calls from java instead of flash


I need to be able to make amf calls from java instead of from flash.  I
have an openamf project and we are going to production in a couple of
months.  I need to stress the J2EE container, so I am working on a
utility.  Do to the complexity of the stress utility I am writing it in
Java.  I was hoping I could make amf calls from java using the api or
creating my own.  

Is there anything already out there so I don't have to reinvent the
wheel?  If not, I was hoping someone could point me in right direction
for putting the calls together.

Thanks,

S. Jackson


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide Read honest & candid
reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=ick
_______________________________________________
Openamf-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openamf-user



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide Read honest & candid
reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=ick
_______________________________________________
Openamf-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openamf-user



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide Read honest & candid
reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=ick
_______________________________________________
Openamf-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openamf-user


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide Read honest & candid
reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=ick
_______________________________________________
Openamf-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openamf-user



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide Read honest & candid
reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=ick
_______________________________________________
Openamf-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openamf-user



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.