WebORB for PHP mod adding RemoteObject source attribute support

Posted on September 23, 2006 | 4 comments

In my first attempt with WebORB for PHP I came across an issue that was not keen with the examples I was trying to use. The issue had to do with using the “source” attribute on the RemoteObject class. The reason behind the missing feature in WebORB for PHP was that they modeled their services config files after FDS, which is JavaAdapter based. My examples are based on ColdFusion and use the standard services-config.xml <source>*</source> attribute defined for the “ColdFusion” destination, which is created by the ColdFusion connectivity feature in 7.0.2.

It took me some digging around to find out why this feature caused a little confusion for us. For those using FDS and not ColdFusion you might not even know it is possible to define a destination with <source>*</source> . It turns out that the FDS documentation states that the <source>*</source> attribute in the service configuration files has to be a valid reference to a class on the remote server. It wasn’t til I went straight to the RemoteObject class documentation that I put the missing pieces together. See the below text from the source attribute of the RemoteObject class.

Lets you specify a source value on the client; not supported for destinations that use the JavaAdapter. This allows you to provide more than one source that can be accessed from a single destination on the server.

livedoc link

It states that the “source” attribute is not supported for JavaAdapters. Since the PHP AMF3 server packages are not Java they should or can support the source attribute. To this end I have modified the WebORB for PHP package to make this feature work. The change only need to be applied to one file but it took me some time to narrow it down to that file, hehe. The file is “Weborb\V3Types\ReqMessage.php”. You can obtain the code via download as a zip or see the source at the end of the post.

Just copy the file over the ReqMessage.php file you have in your current install of WebORB for PHP and it will work.

[php]
/**
* Copyright (C) 2006 Renaun Erickson (modifications)
* Modified on 2006.09.23
*
*/

/*******************************************************************
* ReqMessage.php
* Copyright (C) 2006 Midnight Coders, LLC
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The software is licensed under the GNU General Public License (GPL)
* For details, see http://www.gnu.org/licenses/gpl.txt.
********************************************************************/

require_once(WebOrb . “V3Types/V3Message.php”);

class ReqMessage
extends V3Message
{
public $operation;
public $source;
public $messageRefType;

public function setOperation($operation)
{
$this->operation = $operation;
}

public function getOperation()
{
return $this->operation;
}

public function setSource($source)
{
$this->source = $source;
}

public function getSource()
{
return $this->source;
}

public function setMessageRefType($value)
{
$this->messageRefType = $value;
}

public function getMessageRefType()
{
return $this->messageRefType;
}

public function execute(Request $request)
{
Log::log(LoggingConstants::DEBUG, “Called”);
Log::log(LoggingConstants::INFO, “Operation:” . $this->operation);

if (((“5″ == $this->operation) || (“2″ == $this->operation) || (“0″ == $this->operation))
&& is_numeric($this->operation))
{
return new AckMessage($this->messageId, $this->clientId, null);
}
else
{

if(is_null($this->body->getBody()))
{
$arr = array(0);
$this->body->setBody($arr);
}
else if(!is_array($this->body->getBody()))
{
$arr = array($this->body->getBody());
$this->body->setBody($arr);
}

try
{

$resolvedName = ServiceRegistry::getMapping( $this->destination );
if( $resolvedName == “*” ) {
$context = ServiceRegistry::getContext( $this->destination );
ServiceRegistry::addMapping( $this->destination, $this->source, $context );
}

$returnValue = Invoker::handleInvoke(
$request,
$this->destination,
$this->operation,
$this->body->getBody());

return new AckMessage( $this->messageId, $this->clientId, $returnValue );
}
catch( Exception $e )
{
Log::log( LoggingConstants::EXCEPTION, “method invocation exception”, $e );
return new ErrMessage( $this->messageId, $e );
}
}
}
}

?>[/php]

  • http://blogs.adobe.com/mikepotter/ Mike Potter

    For those of you looking for this file, its in the V3Types directory.

    Mike

  • http://www.renaun.com Renaun Erickson

    Thanks Mike, I guess I should have mentioned that.

  • http://www.familian.net david familian

    i havde tried thsi example and I get

    Fault: [RPC Fault faultString="Channel disconnected" faultCode="Client.Error.DeliveryInDoubt" faultDetail="Channel disconnected before an acknolwedgement was received"] Msg: (mx.messaging.messages::ErrorMessage)#0
    body = (Object)#1
    clientId = (null)
    correlationId = “1B23DA3D-5DAA-1E1E-C9C2-3517151CE573″
    destination = “”
    extendedData = (null)
    faultCode = “Client.Error.DeliveryInDoubt”
    faultDetail = “Channel disconnected before an acknolwedgement was received”
    faultString = “Channel disconnected”
    headers = (Object)#2
    messageId = “CBA7C283-9D78-F242-D756-35171D3E7568″
    rootCause = (null)
    timestamp = 0
    timeToLive = 0

    i used you regmessage.php.

    also the zip file for the regmessage.php does not work.

    thanks

    david

  • http://www.renaun.com Renaun Erickson

    I have not tried this example with the latest WebORB for PHP. The Channel disconnect here seems like something WebORB is sending back when something has broke (basially no response is happening).