RE: Making amf calls from java instead of flash
"Jackson, Stephen" <[email protected]>
| Newsgroups | gmane.comp.java.openamf.user |
|---|---|
| Message-ID | <3428D9627CC79A4ABF37A519431D98122F03B7@nmr001oldmsx05.enterprisenet.org> |
Thanks, this is exactly what I was looking for. -----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=click