PDA

View Full Version : Recieving a data stream?


donb
04-21-06, 05:38 PM
I have a vendor who will be sending inventory updates. The code that they send the updates with looks like this.

if (strXMLResponse.length() > 10)
{
httpConnection = new HTTPConnection(new URL (server));
// httpConnection.setDefaultHeaders(headers);
rsp = httpConnection.Post(server, strXMLResponse, headers);
System.out.println("rsp content type = " + rsp.getHeader("Content-Type"));
printout.writeBytes(strXMLResponse);
}
printout.flush ();

I need a suggestion as to how I should recieve the data. I would like to do it with a small miva script that simply recieved the stream and writes to a file but I am not quite clear on how to setup recieving vars.



Any suggestions? I am not a perl guru. I know just enought to create havoc.


Thanks


Donb

Kent Multer
04-21-06, 07:30 PM
I don't know perl myself, but the call to "httpConnection.Post" certainly suggests that this code is going to try and send data to your store by an HTTP post. Miva scripts can receive these, but the format of the data may need to be changed slightly. If the text is pure XML, you'll need something like "xml=" added at the beginning, so that it looks like a normal form submission, as if a user had typed it into a box on a Web page somewhere. I think that's correct -- I've done plenty of Miva modules that send XML, or receive it via MvCALL. But I've never written a script to reply directly to a raw-XML request. Anybody else have some advice?

aGorilla
04-23-06, 08:01 PM
It _might_ be available as 'arg2'.

post_send.mvc
<MvCALL ACTION="http://localhost/post_recv.mvc?%3Cxml%3E%3Cthis%3Eis%20a%20test%3C% 2Fthis%3E%3C%2Fxml%3E" METHOD="POST">
<MvASSIGN NAME="l.resp" VALUE="{l.resp $ callvalue}">
</MvCALL>
<MvEVAL EXPR="{l.resp}">


post_recv.mvc
<MvEVAL EXPR="{encodeentities(arg2)}">

result
<xml><this>is a test</this></xml>