Sounds like some good progress Matt.
The XSD files I believe you can find under /opt/BESServer/Reference
, but you should still be able to make the call without actually having your hands on them. They are there for your own reference though if you want to look at them.
So when you exported it, you probably would end up with something like this (in this example, I’m running a 3 step plan against a fictitious MYBESSERVER
host. In each step, I’m targeting the host only by name, but you could equally be targeting by name and ID if you wanted to):
<?xml version="1.0" encoding="UTF-8"?>
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
<SingleAction>
<Title>Simple Plan</Title>
<Relevance>false</Relevance>
<ActionScript MIMEType="application/x-sh">#!/plan/xml
<?xml version="1.0" encoding="UTF-8"?>
<plan xmlns="http://iemfsa.tivoli.ibm.com/AutomationPlanAction" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" source-plan-id="2494" prefetch="false" pending-restart="PausePlan" source-plan-site-url="http://MYBESSERVER:52311/cgi-bin/bfgather.exe/actionsite">
<plan-steps>
<step id="101">
<fixlet fixlet-id="34" site-url="http://MYBESSERVER:52311/cgi-bin/bfgather.exe/actionsite" name="Simple%20Task" action-name="Action1" modification-time="Tue, 05 Aug 2014 16:46:22 +0000" >
<relevance><![CDATA[true]]></relevance>
<action-script mime-type="application/x-Fixlet-Windows-Shell"><![CDATA[// Enter your action script here
parameter "x" = "y"]]></action-script>
<success type="RunToCompletion"/>
</fixlet>
<targets>MYBESSERVER
</targets>
</step>
<step id="102">
<fixlet fixlet-id="34" site-url="http://MYBESSERVER:52311/cgi-bin/bfgather.exe/actionsite" name="Simple%20Task" action-name="Action1" modification-time="Tue, 05 Aug 2014 16:46:22 +0000" >
<relevance><![CDATA[true]]></relevance>
<action-script mime-type="application/x-Fixlet-Windows-Shell"><![CDATA[// Enter your action script here
parameter "x" = "y"]]></action-script>
<success type="RunToCompletion"/>
</fixlet>
<targets>MYBESSERVER
</targets>
</step>
<step id="103">
<fixlet fixlet-id="34" site-url="http://MYBESSERVER:52311/cgi-bin/bfgather.exe/actionsite" name="Simple%20Task" action-name="Action1" modification-time="Tue, 05 Aug 2014 16:46:22 +0000" >
<relevance><![CDATA[true]]></relevance>
<action-script mime-type="application/x-Fixlet-Windows-Shell"><![CDATA[// Enter your action script here
parameter "x" = "y"]]></action-script>
<success type="RunToCompletion"/>
</fixlet>
<targets>MYBESSERVER
</targets>
</step>
</plan-steps>
<execution-order>
<step id="101" depends="">
<on-failure action="StopPlan" targets="IncludeFailed" threshold="0"/>
</step>
<step id="102" depends="101">
<on-failure action="StopPlan" targets="IncludeFailed" threshold="0"/>
</step>
<step id="103" depends="102">
<on-failure action="StopPlan" targets="IncludeFailed" threshold="0"/>
</step>
</execution-order>
<plan-settings>
<boolean-setting name="notification-include-summary"><![CDATA[true]]></boolean-setting>
<boolean-setting name="notification-include-recipient"><![CDATA[true]]></boolean-setting>
</plan-settings>
</plan></ActionScript>
<SuccessCriteria Option="RunToCompletion"></SuccessCriteria>
<Settings>
...
</Settings>
<SettingsLocks>
...
</SettingsLocks>
<IsUrgent>false</IsUrgent>
</SingleAction>
</BES>
The contents of the <ActionScript>
element is what we’re interested in - this is the plan action XML content. As I mentioned, you’re dealing with an XML document inside another XML document, so that’s why you see all the “<
” and “>
” all over the place.
But, it sounds like you’ve already got to grips with this part and you now just want to get it back into the system.
Actually, you could probably use the actions
REST resource to create the action, that might even be better.
Try a HTTP POST to the URL below, specifying the ContentType
header as application/xml
and writing your updated XML document to the body of the request (that means the whole document, not just the part inside <ActionScript>
. It should be in the same format as the example I’ve given above, which is basically the same format as you originally got it back from REST to begin with) :
https://<bes-server>:52311/api/actions
I’m definitely not a perl guy, but I’ve had a look around and I think something like this might do it for you (though not actually tested):
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $server_endpoint = "https://<bes-server>:52311/api/actions";
# set custom HTTP request header fields
my $req = HTTP::Request->new(POST => $server_endpoint);
$req->header('content-type' => 'application/xml');
# add POST data to HTTP request body
my $post_data = "<updated-xml-content>";
$req->content($post_data);
my $resp = $ua->request($req);
if ($resp->is_success) {
my $message = $resp->decoded_content;
print "Received reply: $message\n";
}
else {
print "HTTP POST error code: ", $resp->code, "\n";
print "HTTP POST error message: ", $resp->message, "\n";
}
Please let me know how you get on with this.