Access ColdFusion services from a PHP server

To access ColdFusion services from PHP:

  1. Install PHP

  2. Use a library or framework, which helps convert WSDL to PHP classes, for example, "WSO2 Web services Frame Work for PHP".

  3. Invoke the class with required parameters.

    The following example shows a section of a PHP page that adds a border to an image:

    $input = new AddBorder(); 
    //Fill in the class fields of $input to match your business logic 
    $input->serviceusername = "myuser"; 
    $input->servicepassword = "mypassword"; 
    $input->source = "http://myPHPSite/Images/image.jpg"; 
    $input->thickness = "30"; 
    $input->color = "blue"; 
    $input->bordertype = ""; 
    // call the operation 
    $response = $proxy->AddBorder($input);

    In this code snippet,

    serviceusername is the user name set in the ColdFusion administrator with the permission to access the specific service being requested.

    servicepassword is the password set for the service user name.

    source is the source URL of the image in the PHP server.Other attributes are the same as the ImageAddborder() ColdFusion function.

Batch operation on Image:

The following code performs multiple operations on an uploaded image such as batchOperation() to crop an image and add a border to it.
$input = new batchOperation(); 
//TODO: fill in the class fields of $input to match your business logic 
//Crop 
$element1 = new Element(); 
$element2 = new Element(); 
$element3 = new Element(); 
$element4 = new Element(); 
$elementArray1 = new ArrayOf_xsd_anyType(); 
$element1->key = 'x'; 
$element1->value = '10'; 
$element2->key = 'y'; 
$element2->value = '10'; 
$element3->key = 'width'; 
$element3->value = '200'; 
$element4->key = 'height'; 
$element4->value = '200'; 
$elementArray1->item[0] = $element1; 
$elementArray1->item[1] = $element2; 
$elementArray1->item[2] = $element3; 
$elementArray1->item[3] = $element4; 
$ElementcollectionCrop = new Elementcollection(); 
$ElementcollectionCrop->key = 'Crop'; 
$ElementcollectionCrop->value = $elementArray1; 
//AddBorder 
$element5 = new Element(); 
$element6 = new Element(); 
$element7 = new Element(); 
$elementArray2 = new ArrayOf_xsd_anyType(); 
$element5->key = 'thickness';$element5->value = '30'; 
$element6->key = 'color'; 
$element6->value = 'green'; 
$element7->key = 'bordertype'; 
$element7->value = ''; 
$elementArray2->item[0] = $element5; 
$elementArray2->item[1] = $element6; 
$elementArray2->item[2] = $element7; 
$ElementcollectionAddBorder = new Elementcollection(); 
$ElementcollectionAddBorder->key = 'AddBorder'; 
$ElementcollectionAddBorder->value = $elementArray2; 
$input->serviceusername = "myuser"; 
$input->servicepassword = "mypassword"; 
$input->source = "http:/<php server>:<port>/image.jpg"; 
$input->attributes = 
array($ElementcollectionCrop,$ElementcollectionAddBorder); 
// call the operation 
$response = $proxy->batchOperation($input);