How to save XML file to a hypothetical URL?

Hi,

We want to save the component values into XML file and save it on to a hypothetical URL. We tried with fpmi.file.writeFile(), which allows to save the file to Local drive but not to the URL. We also tried with fpmi.net.httpPost() like:

[code]vText = “1002420”

fpmi.net.httpPost(“http://localhost:7280/test/mydata/productiondata.xml”, “text/xml”, vText)
[/code]

When we run the code, Is doesn’t shown any error or exception. However, it is not saving the file to specified path.

Can we save XML to the URL, as we can send XML message to a hypothetical URL using fpmi.net.httpPost().

Are you trying to save the file to a network drive or is there a web service that you post the data to?

The system.file.writeFile writes data to some file on the local drive or a network drive. The system.net.httpPost posts the XML to some web service.

Carl,

What we are essentially trying to do is:

  1. Generate an automated xml file every 1 minute that will include the production data such as counts for the day, downtime, runtime % by machine id

  2. This file is then accessed by a html javascript based mobile app for display of the information on iphone and other mobiles using javascript api

What we have tried:

  1. We have put a timer on a window and whenever the window is opn the timer will run a script to save the current production record as above into a saved file. There are two obvious problems to this approach

prob 1: The window has to be open (so we need to figure out how to run a global script at the gateway level that wills ave the file to our desginated url location. How do we achieve this without running a project or opening a window; in the background

prob 2: the file location to be specified in the writefile function either does not allow or we do not know how to use it; a url location where we can save the file. This is probably a parameter format issue for the location part of the writefile function which we need to understand.

We would appreciate your help.

[quote=“pdalwalla”]prob 1: … How do we achieve this without running a project or opening a window; in the background[/quote]Use Ignition - it has Gateway-scoped timer scripts. This feature will not be back-ported to FactoryPMI

[quote=“pdalwalla”]prob 2: the file location to be specified in the writefile function either does not allow or we do not know how to use it; a url location where we can save the file. This is probably a parameter format issue for the location part of the writefile function which we need to understand.[/quote]Ok, what is the path or URL? Please do not give me something that starts with HTTP - you can’t “save” a file to an HTTP address. This is meaningless. You can POST to HTTP like Travis suggested, but I don’t think you’re trying to do that…

Your plan is really 3 steps - fill in #2 for me and maybe I can help more

#1 Generate XML file on a timer
#2 Put this file somewhere so that…
#3 A mobile/javascript system can read it and serve up information to phones.

Its the “somewhere” that I’m not clear on.

If you don’t want a client running, I’d use HTML/PHP (or Jython :wink: )/Javascript to grab information from the database and create your webpage.

Carl
#2 Somewhere would be a location on the main server which hosts FPMI. so it is a question of the format of path location; that might help us.

Jordan,
Javascript would be a good option; we have tried that but we just wanted t explore what can be done through the gateway and FPMI.

Its the server that is running FPMI? So the path would be something like:

[tt]C:\myfolder\xmldata\myfile.xml[/tt]

The double backslashes are required for python strings to create a single backslash.