binding.soap dont work in server Linux

5 views
Skip to first unread message

Valverde

unread,
Mar 4, 2008, 3:05:19 PM3/4/08
to phpsoa
Hi!

The code below works fine in Apache+Windows but don't work in Apache
+linux

//Result.php
<?php
require 'SCA/SCA.php';

/**
* @service
* @binding.soap
*/
class Result
{
/**
*
* @param string $input
* @return string $output
*/
function getResult($input)
{
return "Result: $input";
}
}
?>

// client.php
<?php

$service = new SoapClient('http://localhost/Result.php?wsdl');


try
{
$return = $service->getResult('test');

echo "<pre>";
echo var_dump($return);
echo "</pre>";
}
catch (SoapFault $soapFault)
{
echo "<pre>";
echo var_dump($soapFault);
echo "</pre>";

echo "Request :<br>";
echo "<pre>";
echo print_r(htmlentities($service->__getLastRequest()));
echo "</pre>";

echo "Response :<br>";
echo "<pre>";
echo print_r(htmlentities($service->__getLastResponse()));
echo "</pre>";
}
?>

the errors are:
public 'faultstring' => string 'Bad Request' (length=11)
public 'faultcode' => string 'SOAP-ENV:Client' (length=15)
Anyone help me?

Matthew Peters

unread,
Mar 10, 2008, 1:13:03 PM3/10/08
to phpsoa
Sorry to hear you are having difficulties. I just tried out the
samples you supplied below and they *do* work for me on Linux so let's
begin by comparing versions.

I am running on Red Hat Linux and PHP 5.2.3. Here is the start of the
output from php -i

phpinfo()
PHP Version => 5.2.3

System => Linux localhost.localdomain 2.4.21-20.EL #1 Wed Aug 18
20:58:25 EDT 2004 i686
Build Date => Jun 20 2007 08:17:41
Configure Command => './configure' '--enable-soap' '--with-openssl'
'--with-xmlrpc' '--with-zlib'

What level of php and what level of SCA_SDO are you on?

Matthew

Valverde

unread,
Mar 11, 2008, 8:30:17 AM3/11/08
to phpsoa
I think that my problem is with HTTP_RAW_POST_DATA.
I tried to create a pure server and client with native soap functions
and then didn't work too.
But when I put this code below to create the server and works fine!!!

<?php
if(!$HTTP_RAW_POST_DATA)
{
$HTTP_RAW_POST_DATA = file("php://input");
}

function getCliente{.....}

$server = new SoapServer("loja.wsdl");
$server->addFunction("getCliente");
$server->handle($HTTP_RAW_POST_DATA);
?>

I still don't try this procedure with SCA. When i do this, i put this
results here...
I'm expert in PHP and newcomer in SCA_SDO.

Sorry for my bad english, i am from Brasil.
Thanks

On 10 Mar, 14:13, Matthew Peters <matthew.f.pet...@googlemail.com>
wrote:

Matthew Peters

unread,
Mar 12, 2008, 6:43:58 AM3/12/08
to phpsoa
Hi, thanks for this info. This is interesting. I do not quite know
what is going on.

However, at the bottom of ...../PEAR/SCA/Bindings/soap/
ServiceRequestHandler.php you'll see the lines:
global $HTTP_RAW_POST_DATA;
$server->handle($HTTP_RAW_POST_DATA);

This is where we pick up the raw post data and pass it in to the Soap
Server. We already had to change this once before when something
changed inside the Soap Server, perhaps something has changed again.
Anyway, perhaps if you include your test and assignment from php://input
into our ServiceRequestHandler.php it will work.

Your English is fine by the way!!

Matthew

Caroline Maynard

unread,
Mar 18, 2008, 9:12:48 AM3/18/08
to php...@googlegroups.com
Matthew Peters wrote:
> Hi, thanks for this info. This is interesting. I do not quite know
> what is going on.
>
> However, at the bottom of ...../PEAR/SCA/Bindings/soap/
> ServiceRequestHandler.php you'll see the lines:
> global $HTTP_RAW_POST_DATA;
> $server->handle($HTTP_RAW_POST_DATA);
>
> This is where we pick up the raw post data and pass it in to the Soap
> Server. We already had to change this once before when something
> changed inside the Soap Server, perhaps something has changed again.
> Anyway, perhaps if you include your test and assignment from php://input
> into our ServiceRequestHandler.php it will work.
>

There's a php.ini directive which is relevant to this behaviour:
always_populate_raw_post_data

Might be worth experimenting with, but I wonder if it would be a
performance hit. I agree with Matthew that using php://input directly in
the service request handler is the way to go.

Valverde

unread,
Mar 25, 2008, 12:59:31 PM3/25/08
to phpsoa
The code bellow works fine. But just i used the client in wsdl-mode,
like this: $service = new SoapClient('http://localhost/Result.php?
wsdl');
In this case the function 'getResult' didn't get the value of $input
variable.
The soap-envelope sent was:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:ns1="http://Result">
<SOAP-ENV:Body><ns1:getResult/></SOAP-ENV:Body>
</SOAP-ENV:Envelope>

and the return was:

array
0 => string 'getResultResponse getResult(getResult
$getResultRequest)' (length=60)

object(stdClass)[2]
public 'getResultReturn' => string 'Result:' (length=6)


Pay attention in the soap-envelope the $input was not sent.


Now, when i tried to use the non-wsdl mode like this:
$service = new SoapClient(null, array("location" => "http://localhost/
Result.php?wsdl",
"uri" => "http://Result"));

the envelope sent was:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:ns1="http://Result" xmlns:xsd="http://www.w3.org/2001/
XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-
ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:getResult>
<param0 xsi:type="xsd:string">test</param0>
</ns1:getResult>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

and the return was.....

SoapFault Object
(
[message:protected] => looks like we got no XML document
[string:private] =>
[code:protected] => 0
[file:protected] => /localhost/client.php
[line:protected] => 23
[trace:private] => Array
(
[0] => Array
(
[file] => /localhost/client.php
[line] => 23
[function] => __soapCall
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => getResult
[1] => Array
(
[0] => test
)

)

)

)

[faultstring] => looks like we got no XML document
[faultcode] => Client
[faultcodens] => http://schemas.xmlsoap.org/soap/envelope/
)

and I note that the function getResult was never call (i track it with
error_log())!!!


Anyone help me?

//Result.php

<?php

global $HTTP_RAW_POST_DATA;
if(!$HTTP_RAW_POST_DATA)
{
$f = file("php://input");
$HTTP_RAW_POST_DATA = implode(" ", $f);
Reply all
Reply to author
Forward
0 new messages