Hi,
I am trying to integrate workflows from PHP code using the orchestrator SOAP API.
<?php
try
{
$parameters=array(username=>"username",password=>"passwd");
$client = new SoapClient('https://vcoserver:8281/vco/vmware-vmo-webcontrol/webservice?WSDL');
$result = $client->getAllWorkflows($parameters);
foreach($result as $item)
{
foreach($item as $work)
{
echo $work->name;
echo "<br>";
echo "id";
echo $work->id;
echo "<br />";
}
}
}
catch(Exception $e)
{
echo $e;
}
?>
I do not see any error/exception, but do not see any output as well.
Am i missing anything?
Could you use
print curl_error($curl);
after curl_exec to check if there are some errors?
If there is some SSL certificate error, like 'SSL certificate problem: unable to get local issuer certificate', you can either install root certificates (Google for information how to do so), or disable verification of peer certificates in CURL with something like:
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
This is not the answer you are expecting but the SOAP API is going to be deprecated. I am not sure how you can use the REST API from PHP but if you need to invest your time it should be with REST.
Thanks for the heads-up.
Hi,
I tried your code as-is and it worked just fine (on Windows 7 + PHP 5.4.26 + vCO 5.5.1).
What happens if you open SOAP API URL in a browser https://vcoserver:8281/vco/vmware-vmo-webcontrol/webservice?WSDL ?
I can see the WSDL in the browser.
But still facing the same issue. I am not sure if I am missing any dependencies.
On the other hand, is it true that SOAP API are going to be deprecated? If so, I don't want to invest effort trying this.
Please suggest
Yes, the current plan is to deprecate SOAP API soon and remove them later, probably around 2016.
In that case, can you please help me achieve the same with REST API?
Can you please share a sample code?
I have very limited PHP knowledge, but something like this should work:
<?php
try
{
$cred = sprintf('Authorization: Basic %s', base64_encode("myusername:mypassword") );
$opts = array(
'http'=>array(
'method'=>'GET',
'header'=>$cred)
);
$url='https://vcoserver:8281/vco/api/workflows'; // vCO 5.5 REST API to get all workflows
$ctx = stream_context_create($opts);
$handle = fopen($url, 'r', false, $ctx);
$response = stream_get_contents($handle);
$result = json_decode($response);
foreach($result as $item)
{
foreach($item as $work)
{
var_dump( $work );
}
}
}
catch(Exception $e)
{
echo $e;
}
?>
Hi Deepthy try this
/*parameters.inc*/
<?php
$vco_server = "10.1.1.1"; //your vco ip
$vco_user = "administrator";
$vco_pass = "secret";
?>
/*findworkflow.php*/
<?php
include ("parameters.inc");
$vco = new SoapClient('https://' . $vco_server . ':8281/vmware-vmo-webcontrol/webservice?WSDL');
$param = array(username=>$vco_user,password=>$vco_pass);
$result = $vco->getAllWorkflows($param);
foreach ($result as $item)
{
foreach ($item as $work)
{
echo $work->name;
echo "<br>";
echo "ID=";
echo $work->id;
echo "<br>";
echo "$work->description";
echo "<br>";
echo "<br>";
}
}
?>
If error still persists, please open the your web server log, if you running into linux using apache search at /var/log/apache2/error.log and
If you wanna execute the workflow based on workflow id just use executeWorkflow() and please refer to VCO web services guide....
Ilian,
Thanks a ton!! your code works like a charm
I am trying to figure out how to execute a workflow, but in vain.
Can you give me a clue on what parameters need to be passed for starting a workflow execution.
Please have a look at this : How to use the REST API to Start a Workflow
The REST client is not working for me.
GET method is itself not working. Not sure what I missed.
If you are using vCO5.5 or higher use https://server:8281/vco/api/....
The docu is outdated for this URLs
We do have vco5.5 installed.
Is there any other documentation available for this?
online doc is available for the REST API https://vcoserver:8281/vco/api
TYPO ... 😉 online doc is available for the REST API https://vcoserver:8281/vco/api/docs
Tx Andreas. I need to get another coffe
Hi,
I am now able to execute workflows through REST-client
I am trying the same with the following php code using CURL but the HTTP code is '0'
Can you please point out what I am missing.
<?php
$service_url = 'https://vcoserver:8281/vco/api/workflows/719f3902-6628-469a-a8fe-ed68501d961e/executions/';
//echo $service_url;
try
{
$curl = curl_init($service_url);
// $curl_post_data_xml=new SimpleXMLElement('<execution-context xmlns="http://www.vmware.com/vco"><parameters></parameters></execution-context>');
$curl_post_data_xml='<execution-context xmlns="http://www.vmware.com/vco"><parameters></parameters></execution-context>';
curl_setopt($curl,CURLOPT_CUSTOMREQUEST,"POST");
curl_setopt($curl,CURLOPT_HTTPHEADER, array('Accept: application/json','Content-Type: application/xml'));
curl_setopt($curl,CURLOPT_USERPWD,"username:password");
curl_setopt($curl,CURLOPT_HTTPAUTH,CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data_xml);
$curl_response = curl_exec($curl);
$code = curl_getinfo($curl,CURLINFO_HTTP_CODE);
echo $code;
curl_close($curl);
}
catch(Exception $ec)
{
echo $ec;
}
?>
Could you use
print curl_error($curl);
after curl_exec to check if there are some errors?
If there is some SSL certificate error, like 'SSL certificate problem: unable to get local issuer certificate', you can either install root certificates (Google for information how to do so), or disable verification of peer certificates in CURL with something like:
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
Thanks a ton !
It worked.