WebORB for PHP mod adding RemoteObject source attribute support

September 23rd, 2006

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:
  1. /**
  2. *    Copyright (C) 2006 Renaun Erickson (modifications)
  3. *    Modified on 2006.09.23
  4. *
  5. */
  6.  
  7. /*******************************************************************
  8. * ReqMessage.php
  9. * Copyright (C) 2006 Midnight Coders, LLC
  10. *
  11. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  12. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  13. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  14. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  15. * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  16. * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  17. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  18. *
  19. * The software is licensed under the GNU General Public License (GPL)
  20. * For details, see http://www.gnu.org/licenses/gpl.txt.
  21. ********************************************************************/
  22.  
  23. require_once(WebOrb . "V3Types/V3Message.php");
  24.  
  25. class ReqMessage
  26. extends V3Message
  27. {
  28. public $operation;
  29. public $source;
  30. public $messageRefType;
  31.  
  32. public function setOperation($operation)
  33. {
  34. $this->operation = $operation;
  35. }
  36.  
  37. public function getOperation()
  38. {
  39. return $this->operation;
  40. }
  41.  
  42. public function setSource($source)
  43. {
  44. $this->source = $source;
  45. }
  46.  
  47. public function getSource()
  48. {
  49. return $this->source;
  50. }
  51.  
  52. public function setMessageRefType($value)
  53. {
  54. $this->messageRefType = $value;
  55. }
  56.  
  57. public function getMessageRefType()
  58. {
  59. return $this->messageRefType;
  60. }
  61.  
  62. public function execute(Request $request)
  63. {
  64. Log::log(LoggingConstants::DEBUG, "Called");
  65. Log::log(LoggingConstants::INFO, "Operation:" . $this->operation);
  66.  
  67. if ((("5" == $this->operation) || ("2" == $this->operation) || ("0" == $this->operation))
  68. && is_numeric($this->operation))
  69. {
  70. return new AckMessage($this->messageId, $this->clientId, null);
  71. }
  72. else
  73. {
  74.  
  75. if(is_null($this->body->getBody()))
  76. {
  77. $arr = array(0);
  78. $this->body->setBody($arr);
  79. }
  80. else if(!is_array($this->body->getBody()))
  81. {
  82. $arr = array($this->body->getBody());
  83. $this->body->setBody($arr);
  84. }
  85.  
  86. try
  87. {
  88.  
  89. $resolvedName = ServiceRegistry::getMapping( $this->destination );
  90. if( $resolvedName == "*" ) {
  91. $context = ServiceRegistry::getContext( $this->destination );
  92. ServiceRegistry::addMapping( $this->destination, $this->source, $context );
  93. }
  94.  
  95. $returnValue = Invoker::handleInvoke(
  96. $request,
  97. $this->destination,
  98. $this->operation,
  99. $this->body->getBody());
  100.  
  101. return new AckMessage( $this->messageId, $this->clientId, $returnValue );
  102. }
  103. catch( Exception $e )
  104. {
  105. Log::log( LoggingConstants::EXCEPTION, "method invocation exception", $e );
  106. return new ErrMessage( $this->messageId, $e );
  107. }
  108. }
  109. }
  110. }
  111.  
  112. ?>

Entry Filed under: Flex,AMF,PHP, PHP, Rich Internet Applications

4 Comments

  • 1. Mike Potter  |  2006-09-28 at 7.12 am

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

    Mike

  • 2. Renaun Erickson  |  2006-09-28 at 8.39 am

    Thanks Mike, I guess I should have mentioned that.

  • 3. david familian  |  2007-06-16 at 8.18 am

    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

  • 4. Renaun Erickson  |  2007-06-21 at 12.29 pm

    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).


Disclaimer: I work as a Flash/Flex Developer for Adobe Systems Incorporated. The opinions expressed here represent my own and not those of my employer.

My Amazon.com Wish List

Calendar

September 2006
S M T W T F S
« Aug   Oct »
 12
3456789
10111213141516
17181920212223
24252627282930

Most Recent Posts


Flex.org - The Directory for Flex