Problems with message binding

7 views
Skip to first unread message

jpuerta

unread,
Feb 29, 2008, 4:31:11 PM2/29/08
to phpsoa, jvi...@ve.ibm.com
Greetings...

We have been trying to use the message binding with SCA, but we have
been unsuscessful...
We were trying to do this as shown here:
http://www.osoa.org/display/PHP/binding.message+Binding+Documentation
But when we try to generate the Message Service Description (http://
yummyphpprojjpuerta/services/activemqtest/TestService.php?msd), we
obtain this error:

Fatal error: Class 'SCA_Bindings_ms_ServiceDescriptionGenerator' not
found in /usr/local/php/lib/SCA_SDO-1.2.3/SCA/Bindings/message/
ServiceRequestHandler.php on line 49

We also noticed, that when we load the SAM extension, for some reason,
wsdls generated by SCA have 1 empty line at the beginning of the
document, rendering the xml invalid... the browser complains with this
error:

XML Parsing Error: xml declaration not at start of external entity
Location: http://yummyphpprojjpuerta/services/activemqtest/TestService.php?wsdl
Line Number 2, Column 1:<?xml version="1.0" encoding="UTF-8"?>
^

Many thanks in advance for any help you may offer...

Matthew Peters

unread,
Mar 3, 2008, 6:04:32 AM3/3/08
to phpsoa
Hi, sorry to hear you are having problems.

The Fatal error you are seeing looks odd: the _ms_ in the middle of
the name looks like something somewhere is looking for a binding.ms
rather than binding.message. I propose we try with an exaple that I
know works - I show below a simple example that I have just tried out
on my machine with ActiveMQ 5.0. I am running with the FULMAR branch
of SCA but I don't think that should make any difference.

As for the second error you report, the empty line, one reason for
that can be a blank line in the php script on the receiving end - the
one that is supposed to generate the wsdl. If there is a blank line
before the first <?php, it comes out in the wsdl. In fact if any of
the scripts that are involved in generating the wsdl emit anything
before the <?xml declaration we get trouble - but I hope that the SCA
scripts never do that.

Here is my working example. See if it works for you. It's three files
which for me are all in C:\Program Files\Apache Group\Apache2\htdocs
\Frankfurt\Message
where htdocs is of course the document root for my apache.

Of course you need to start ActiveMQ in one window and
ReceivingService.php in another. You'll see that the test client gets
the receiving service to generate the msd file and writes it out, then
makes a local call to the sending service which sends the magic
initials IBM on queue://receiver

I get a couple of annoying messages from the SAM extension but that is
because I run php with strict messages i.e. show all errors - in any
case they are nothing to worry about.

Good luck and do let me know how you get on.

Matthew


TestClient.php
____________________________________________________________________________________
<?php

include_once "SCA/SCA.php";

$msd = file_get_contents('http://localhost/Frankfurt/Message/
ReceivingService.php?msd');
file_put_contents('./ReceivingService.msd', $msd);


$local_service = SCA::getService('./SendingService.php');
$local_service->send('IBM') . "\n";

?>
______________________________________________________________________________________


SendingService.php
______________________________________________________________________________________
<?php

include "SCA/SCA.php";

/**
* @service
*/

class SendingService {
/**
* @reference
* @binding.message ReceivingService.msd
*/
public $receiving_service;

public function send($str)
{
$this->receiving_service->send($str);
}
}

?>
______________________________________________________________________________________


ReceivingService.php
______________________________________________________________________________________
<?php
include "SCA/SCA.php";

/**
* @service
* @binding.message
* @protocol stomp
* @destination queue://receiver
* @wsdl disabled
*/


class ReceivingService {

public function send($str) {
echo $str . "\n";
}

}
?>
______________________________________________________________________________________

jpuerta

unread,
Mar 3, 2008, 11:06:18 AM3/3/08
to phpsoa
Hello Matthew...

Thank you very much for your help...
I tried the example you provided, but i was unable to get it to
work...
I still get the same error when I try this:

http://yummyphpprojjpuerta/services/activemqtest/ReceivingService.php?msd


Fatal error: Class 'SCA_Bindings_ms_ServiceDescriptionGenerator' not
found in /usr/local/php/lib/SCA_SDO-1.2.3/SCA/Bindings/message/
ServiceRequestHandler.php on line 49

I checked the line 49 in this file, and it looks like this:
SCA_Bindings_ms_ServiceDescriptionGenerator::generateMPD($service_description));

After that I browsed for the same file in the FULMAR branch you were
referring to (http://cvs.php.net/viewvc.cgi/pecl/sdo/SCA/Bindings/
message/ServiceRequestHandler.php?
hideattic=1&view=markup&pathrev=FULMAR), and found that the same line
looks different than the one in the SCA version we downloaded:

SCA_Bindings_message_ServiceDescriptionGenerator::generateMSD($service_description));

we downloaded the SCA_SDO stable version 1.2.3 from here:
http://pecl.php.net/package/SCA_SDO/

Again... thank you for your help
jpuerta

On 3 Mar, 07:04, Matthew Peters <matthew.f.pet...@googlemail.com>
wrote:

Matthew Peters

unread,
Mar 4, 2008, 6:06:06 AM3/4/08
to phpsoa
Good, that sounds as if that has fixed the problem for you. How about
the second one - a blank line in the wsdl? Did you find the source of
the problem for that too?

You'll see I have just released 1.2.4, by the way.

Matthew

On Mar 3, 4:06 pm, jpuerta <jbpuer...@gmail.com> wrote:
> Hello Matthew...
>
> Thank you very much for your help...
> I tried the example you provided, but i was unable to get it to
> work...
> I still get the same error when I try this:
>
> http://yummyphpprojjpuerta/services/activemqtest/ReceivingService.php...

jpuerta

unread,
Mar 4, 2008, 6:04:09 PM3/4/08
to phpsoa
Hi Matthew...

Unfortunately, we have still been unable to run a successful test with
the message binding...
The fatal error complaining about the class with "ms" in the name,
disappeared... creating the msd file works now, but trying with the
example you provided... we run the ReceivingService in one window, and
get the following output:

[root@was6testserver activemqtest]# /usr/local/php/bin/php
ReceivingService.php

Listener for queue://receiver has been started. To exit, press <Ctrl>
+ <C> ...

Activemq is running on another window...
But when we run the test client it still fails displaying the
following error:

Fatal error: Uncaught SCA_RuntimeException: Send Request Failed thrown
in /usr/local/php/lib/SCA_SDO/SCA/Bindings/message/Proxy.php on line
120

At this point we really don't know what we are doing wrong...
We installed activemq 5.0.0 on the localhost and on some other
server... but it made no difference

We are also still getting the blank line generating WSDLs and any
other XML file generated by sca, including the msd file... we still
don't know why this happens... but this behaviour only occurs, when
the sam extension is loaded... without it, all the wsdls are generated
fine...

We are using SCA_SDO version 1.2.4 now...

Any suggestion will be appreciated...
Thank you very much

jpuerta...

On 4 Mar, 07:06, Matthew Peters <matthew.f.pet...@googlemail.com>
wrote:

Jack Zai

unread,
Mar 4, 2008, 11:05:15 PM3/4/08
to phpsoa
Hello,

The blank line in the WSDL may be caused by the carriage return at the
end of file 'php_sam.php' (PECL bug #11034).

In that case, i think you have used the current releases (1.1.0) of
SAM, and I am afeard this version does NOT support some features of
the message binding ( including the STOMP protocol ). Unfortunately,
i've no idea when the next release of SAM becomes available. in the
mean time, you may wish to try a patch file[1] and rebuild SAM
extension yourself. Good luck!

Jack

[1] the patch file can be found at this link http://groups.google.co.uk/group/phpsam/files
(named sam_patch.txt), there is also a zip file contains the whole sam
folder with the latest sources code.
> > > SCA_Bindings_ms_ServiceDescriptionGenerator::generateMPD($service_descripti­on));
>
> > > After that I browsed for the same file in the FULMAR branch you were
> > > referring to (http://cvs.php.net/viewvc.cgi/pecl/sdo/SCA/Bindings/
> > > message/ServiceRequestHandler.php?
> > > hideattic=1&view=markup&pathrev=FULMAR), and found that the same line
> > > looks different than the one in the SCA version we downloaded:
>
> > > SCA_Bindings_message_ServiceDescriptionGenerator::generateMSD($service_desc­ription));
> > > > ___________________________________________________________________________­_________
> > > > <?php
>
> > > > include_once "SCA/SCA.php";
>
> > > > $msd = file_get_contents('http://localhost/Frankfurt/Message/
> > > > ReceivingService.php?msd');
> > > > file_put_contents('./ReceivingService.msd', $msd);
>
> > > > $local_service = SCA::getService('./SendingService.php');
> > > > $local_service->send('IBM') . "\n";
>
> > > > ?>
> > > > ___________________________________________________________________________­___________
>
> > > > SendingService.php
> > > > ___________________________________________________________________________­___________
> > > > <?php
>
> > > > include "SCA/SCA.php";
>
> > > > /**
> > > >  * @service
> > > >  */
>
> > > > class SendingService {
> > > >         /**
> > > >      * @reference
> > > >      * @binding.message ReceivingService.msd
> > > >      */
> > > >         public $receiving_service;
>
> > > >         public function send($str)
> > > >         {
> > > >                 $this->receiving_service->send($str);
> > > >         }
>
> > > > }
>
> > > > ?>
> > > > ___________________________________________________________________________­___________
>
> > > > ReceivingService.php
> > > > ___________________________________________________________________________­___________
> > > > <?php
> > > > include "SCA/SCA.php";
>
> > > > /**
> > > >  * @service
> > > >  * @binding.message
> > > >  * @protocol stomp
> > > >  * @destination queue://receiver
> > > >  * @wsdl disabled
> > > >  */
>
> > > > class ReceivingService {
>
> > > >         public function send($str) {
> > > >                 echo $str . "\n";
> > > >         }
>
> > > > }
>
> > > > ?>
> > > > ___________________________________________________________________________­___________
>
> > > > On Feb 29, 9:31 pm, jpuerta <jbpuer...@gmail.com> wrote:
>
> > > > > Greetings...
>
> > > > > We have been trying to use the message binding with SCA, but we have
> > > > > been unsuscessful...
> > > > > We were trying to do this as shown here:http://www.osoa.org/display/PHP/binding.message+Binding+Documentation
> > > > > But when we try to generate the Message Service Description (http://
> > > > > yummyphpprojjpuerta/services/activemqtest/TestService.php?msd), we
> > > > > obtain this error:
>
> > > > > Fatal error: Class 'SCA_Bindings_ms_ServiceDescriptionGenerator' not
> > > > > found in /usr/local/php/lib/SCA_SDO-1.2.3/SCA/Bindings/message/
> > > > > ServiceRequestHandler.php on line 49
>
> > > > > We also noticed, that when we load the SAM extension, for some reason,
> > > > > wsdls generated by SCA have 1 empty line at the beginning of the
> > > > > document, rendering the xml invalid... the browser complains with this
> > > > > error:
>
> > > > > XML Parsing Error: xml declaration not at start of external entity
> > > > > Location:http://yummyphpprojjpuerta/services/activemqtest/TestService.php?wsdl
> > > > > Line Number 2, Column 1:<?xml version="1.0" encoding="UTF-8"?>
> > > > > ^
>
> > > > > Many thanks in advance for any help you may offer...- Hide quoted text -
>
> - Show quoted text -

Matthew Peters

unread,
Mar 6, 2008, 6:28:59 AM3/6/08
to phpsoa
Jack, thanks for this very timely and authoritative reposnse.

jp, if you want, I can try and build the version of the zip file that
Jack's posting refers to and make sure that our samples run with that
precise level. Or you can try it first. Let me know what you would
like. And...are you on Windows or Linux or something else?

Matthew

On Mar 5, 4:05 am, Jack Zai <za...@hotmail.com> wrote:
> Hello,
>
> The blank line in the WSDL may be caused by the carriage return at the
> end of file 'php_sam.php' (PECL bug #11034).
>
> In that case, i think you have used the current releases (1.1.0) of
> SAM, and I am afeard this version does NOT support some features of
> the message binding ( including the STOMP protocol ). Unfortunately,
> i've no idea when the next release of SAM becomes available. in the
> mean time, you may wish to try a patch file[1] and rebuild SAM
> extension yourself. Good luck!
>
> Jack
>
> [1] the patch file can be found at this linkhttp://groups.google.co.uk/group/phpsam/files

jpuerta

unread,
Mar 6, 2008, 1:16:12 PM3/6/08
to phpsoa
Hello Jack, Matthew...

I downloaded the zipfile, and successfully compiled Jack's version of
the sam extension...
But after loading the extension, php no longer works and we see a
segmentation fault in the logs, so I was unable to test the example...

I am testing all this on Linux...
We have
php 5.2.5
apache 2.2.6
activemq 5.0.0

Thanks
jpuerta


On 6 Mar, 07:28, Matthew Peters <matthew.f.pet...@googlemail.com>
wrote:

Jack Zai

unread,
Mar 10, 2008, 2:41:25 AM3/10/08
to phpsoa
Hello,

Oh, that doesn't looks good. well, be honest i never tested it on
Linux, but I 'm surprised you got a segmentation fault. The most of
changes I made to sam were on php files, those shouldn't affect the
binary you built. The only change I made to C files was the following
two lines which were added to php_sam.c.

REGISTER_STRING_CONSTANT(SAM_CONSTANT_PRIORITY, SAM_CONSTANT_PRIORITY,
CONST_CS | CONST_PERSISTENT);
REGISTER_STRING_CONSTANT(SAM_CONSTANT_TIMETOLIVE,
SAM_CONSTANT_TIMETOLIVE, CONST_CS | CONST_PERSISTENT);

And those are just for registering two constants "SAM_PRIORITY" and
"SAM_TIMETOLIVE". If you had no problem with the original sam, I don't
see how those two lines would cause a segmentation fault when loading
the extension.

Unfortunately, I am currently working on some other project, so I
don't have a running php environment right now, cannot help you out
there. I don't know if Matthew can confirm that my version of sam
works on Linux?


Jack

P.S. Changelog for sam:

1. php_sam.c
- two lines added for registering constants SAM_CONSTANT_PRIORITY
and SAM_CONSTANT_TIMETOLIVE
2. php_sam.php
- slightly changed the if statement in the create() method, for
handling stomp protocol.
- Fixed PECL bug #11034, deleted the carriage return at the end of
the file
3. added file sam_factory_stomp.php
4. created new folder Stomp
5. added file Stomp/Stomp.php
6. added file Stomp/sam_stomp.php
7. added three testcases
> ...
>
> read more »- Hide quoted text -

Matthew Peters

unread,
Mar 10, 2008, 1:50:49 PM3/10/08
to phpsoa
Jack, jpuerta,
I will do as Jack suggests and have a go with this on Linux myself. It
will have to wait for a few days however, I am sorry to say, as I have
a busy few days coming up. If anyone else has time to have a go,
please be my guest.

Matthew
> ...
>
> read more »

jpuerta

unread,
Mar 11, 2008, 11:37:25 AM3/11/08
to phpsoa
Ok....

Looking forward to the results of your test...

Thanks...
jpuerta

On 10 Mar, 13:50, Matthew Peters <matthew.f.pet...@googlemail.com>
> ...
>
> read more »

Matthew Peters

unread,
Mar 14, 2008, 6:56:09 AM3/14/08
to phpsoa
OK, my first attempt failed at the first hurdle. The command "pecl
install sam" failed during the phpize step, complaining because I did
not have XMS present. Yet the documentation says XMS is optional. Do
you have XMS on your system?

I have raised this as a pecl bug also.

Matthew
> ...
>
> read more »
Message has been deleted

Jack Zai

unread,
Mar 17, 2008, 12:39:54 AM3/17/08
to phpsoa
Matthew, sorry i didn't realise that SAM extension cannot be built
without XMS, I thought it was two separate libraries as 'sam' and
'sam_xms'. but in fact, I've just checked the SAM documentation, they
both require XMS as a prerequisite.

However, you also reminded me that the support of Stomp protocol may
work without building the extension. All you need to do is to include
once 'php_sam.php' somewhere in your php script. So for the message
binding, change would made to the if statements, that checks for
existence of SAM, appeared as

in file 'SCA/Bindings/message/Proxy.php' line 46
and in file 'SCA/Bindings/message/RequestTester.php' line 45

replace them with the following code

if ( ! (in_array('sam', get_loaded_extensions())) ) {
if (! include_once('SAM/php_sam.php') )
throw new SCA_RuntimeException("The SAM extension must be
installed");
}

Make sure you copied and replaced all the php files and sub
directories that contains php files, from the zip to where the old SAM
php files were located(e.g. c:\php\pear\SAM or /usr/local/libb/php/
SAM).

And another thing is I found there should be a close bracket '}' in
line 437 of the file 'php_sam.php' which I provided. and that may be
the source causing the segmentation fault. Sorry for the mistake, I
hope that works now.

Jack

On Mar 14, 10:56 am, Matthew Peters <matthew.f.pet...@googlemail.com>
wrote:
> ...
>
> read more »

Matthew Peters

unread,
Mar 20, 2008, 1:33:09 PM3/20/08
to phpsoa
Jack,
I have tried what you suggested here - I have copied all the php files
from the zip file to the right place (which for me is under /usr/local/
lib/php/SAM and I have also installed ActiveMQ 5 and that looks
alright.

When I try to generate the msd file from the ReceivingService.php (as
above) I get the following back:
queue://receiver stomp disabled

Do you have any idea what that might mean? I can start debugging into
the msd file generation but I thought you might have seen it before
and know straightaway.

Matthew
> ...
>
> read more »

Jack Zai

unread,
Mar 20, 2008, 10:34:02 PM3/20/08
to phpsoa
Matthew,
I think that is normal, just because your web browser automatically
hid those xml tags. so if you view page source, you should see
something like this:

<?xml version="1.0" encoding="UTF-8"?>
<tns:MessageServiceDescription xmlns:tns="http://www.example.org/
MessageServiceDescription" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance">
<destination>queue://receiver</destination>
<connectionFactory>
<protocol>stomp</protocol>
</connectionFactory>
<wsdl>disabled</wsdl>
</tns:MessageServiceDescription>

Jack

On Mar 20, 5:33 pm, Matthew Peters <matthew.f.pet...@googlemail.com>
> ...
>
> read more »
Reply all
Reply to author
Forward
0 new messages