Page 1 of 1

PEAR SOAP SIMPLE CLIENT SERVER EXAMPLE RETURNS OBJECT ERROR

Posted: Thu Apr 13, 2006 5:35 am
by MentalWealth
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi all, im new to PEAR SOAP, and am having a few teething troubles. I have searched the web high and low, and still i have a problem. If anyone could spare a few mins.......

My overall soap is working,   i can retrieve the wsdl details from the server script created, and i can get the wsdl link up (getDisco())........when i try to invoke the quoteservice method, i receive an object error(unhandled soap fault error).    I am sure it is just slight syntax, can anyone see where i might be going wrong?

heres my code:

client1.php--------

Code: Select all

<?php 
  include("SOAP/Client.php");
  $wsdl = new Soap_WSDL("stockquote.wsdl");
	
	$client   = $wsdl->getProxy(); 

    echo "<pre>\n"; 
    print($client->getQuote("ibm")); 
    echo "\n"; 
    print($client->getQuote("microsoft"));   
    echo "\n</pre>\n"; 

?>
and server1.php---------

Code: Select all

<?php 
include("SOAP/Server.php");

class QuoteService { 
  var $quotes = array("ibm" => 98.42);   

  function getQuote($symbol) { 
    if (isset($this->quotes[$symbol])) { 
      return $this->quotes[$symbol]; 
    } else { 
      return "Server - Unknown Symbol '$symbol'."; 
    } 
  } 
} 

$server = new Soap_Server; 
$server->_auto_translation = true;
$webservice = new QuoteService();
$server->addObjectMap($webservice,'http://schemas.xmlsoap.org/soap/envelope/');



if (isset($_SERVER['REQUEST_METHOD']) &&
    $_SERVER['REQUEST_METHOD']=='POST') {
    $server->service($HTTP_RAW_POST_DATA);
} else {
    require_once 'SOAP/Disco.php';
    $disco = new SOAP_DISCO_Server($server,'ServerExample');
    header("Content-type: text/xml");
    if (isset($_SERVER['QUERY_STRING'])) {
        echo $disco->getWSDL();
    } else {
        echo $disco->getDISCO();
    }
    exit;
}
?>

and my WSDL : stockquote.wsdl-----------

Code: Select all

<?xml version ='1.0' encoding ='UTF-8' ?> 
<definitions name='StockQuote' 
  targetNamespace='http://example.org/StockQuote' 
  xmlns:tns=' http://example.org/StockQuote ' 
  xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' 
  xmlns:xsd='http://www.w3.org/2001/XMLSchema' 
  xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/' 
  xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/' 
  xmlns='http://schemas.xmlsoap.org/wsdl/'> 

<message name='getQuoteRequest'> 
  <part name='symbol' type='xsd:string'/> 
</message> 
<message name='getQuoteResponse'> 
  <part name='Result' type='xsd:float'/> 
</message> 

<portType name='StockQuotePortType'> 
  <operation name='getQuote'> 
    <input message='tns:getQuoteRequest'/> 
    <output message='tns:getQuoteResponse'/> 
  </operation> 
</portType> 

<binding name='StockQuoteBinding' type='tns:StockQuotePortType'> 
  <soap:binding style='rpc' 
    transport='http://schemas.xmlsoap.org/soap/http'/> 
  <operation name='getQuote'> 
    <soap:operation soapAction='urn:xmethods-delayed-quotes#getQuote'/> 
    <input> 
      <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes' 
        encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> 
    </input> 
    <output> 
      <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes' 
        encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> 
    </output> 
  </operation> 
</binding> 

<service name='StockQuoteService'> 
  <port name='StockQuotePort' binding='StockQuoteBinding'> 
    <soap:address location='http://www.mentalwealthstudios.com/NNEPC2/server1.php'/> 
  </port> 
</service> 
</definitions>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Apr 13, 2006 8:30 am
by MentalWealth
also..........after hadling the errors..............this is the output:

Code: Select all

Error HTTP [ HTTP Response 404 Not Found]

Posted: Thu Apr 13, 2006 1:29 pm
by MentalWealth
hi....again.....................been trying a different example, everything seems to work fine, except i get an HTTP error(listed after the example soap files):

client-----------

Code: Select all

<?
	$namespace = "http://www.mentalwealthstudios.com/NNEPC2/practice2/";
	require_once('SOAP/Client.php');

	$info = new SOAP_client("http://www.mentalwealthstudios.com/NNEPC2/practice2/helloserver.php");
	$params = array("name" => "Peter");
	$response = $info->call("sayhello",$params,$namespace);
	
	if(PEAR::iserror($response)){
		//print_r($response);
		print("Error " . $response->getCode() ." [ " . $response->getMessage() . "]\n");
	}else{	echo $response;}

	echo "\n";
	exit;
?>

server---------

Code: Select all

<?
	require_once("SOAP/Server.php");
	include("helloclass.php");

	$hello = new hello;
	$server = new SOAP_server;
	$server->addObjectMap($hello,'http://www.mentalwealthstudios.com/NNEPC2/practice2/');
	$server->service($GLOBALS['HTTP_RAW_POST_DATA']);
	exit();
?>
class-------------

Code: Select all

<?
	class hello
	{
		function	hello()	
		{
		}
		function	sayhello($name)
		{
			return "Hello " . $name;
		}
		function	saygoodbye($name)
		{
			return "Good Bye " . $name;
		}
	}
?>

error--------------

Code: Select all

Error HTTP [ 
Warning: Cannot modify header information - headers already sent by (output started at /home/mental3/public_html/NNEPC2/practice2/helloclass.php:18) in /home/mental3/pear/SOAP/Server.php on line 264

Warning: Cannot modify header information - headers already sent by (output started at /home/mental3/public_html/NNEPC2/practice2/helloclass.php:18) in /home/mental3/pear/SOAP/Server.php on line 274

Warning: Cannot modify header information - headers already sent by (output started at /home/mental3/public_html/NNEPC2/practice2/helloclass.php:18) in /home/mental3/pear/SOAP/Server.php on line 274

Warning: Cannot modify header information - headers already sent by (output started at /home/mental3/public_html/NNEPC2/practice2/helloclass.php:18) in /home/mental3/pear/SOAP/Server.php on line 274
Hello Peter ]

the "HELLO PETER" string at the end of the error text is the output i am after, this means the name 'peter' has been sent from the client, passed to the assigned server class, and has been appended to the string "HELLO" within a class function, and then sent back for display to the client. Anyone know why i get the HTTP headers error?

please............anyone, im getting desperate for some help on getting SOAP functioning correctly, i need to get cracking with a college web service assignment i said i would complete in PHP SOAP!!

Posted: Thu Apr 13, 2006 1:43 pm
by feyd

Posted: Thu Apr 13, 2006 2:44 pm
by MentalWealth
thanks for the reply.............i understand php headers, i just dont know why i am getting this problem with my SOAP...............

Posted: Thu Apr 13, 2006 3:00 pm
by feyd
it's the exact same situtation. You have output started before the header function was called. The error tells you exactly where the output starts.

Posted: Thu Apr 13, 2006 3:25 pm
by MentalWealth
Hi.thanks again.....didnt understand oupput correctly..........i did have undesired newlines in my file............now i have sorted that, i get an internal system error! :

Code: Select all

Error HTTP [ 
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@mentalwealthstudios.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. 


--------------------------------------------------------------------------------

Apache/1.3.34 Server at www.mentalwealthstudios.com Port 80
]

Posted: Thu Apr 13, 2006 3:35 pm
by MentalWealth
seems their is a dman bug in PEAR.....................http://pear.php.net/bugs/bug.php?id=6744

PROBLEM SOLVED!