PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Problem with crossplatform webservices

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Web Services
View previous topic :: View next topic  
Author Message
rav_nan



Joined: 21 Aug 2007
Posts: 3

PostPosted: Sat Sep 01, 2007 9:35 am    Post subject: Problem with crossplatform webservices Reply with quote

Hey guys can anybody help me with this problem.
i have been trying for the past 10 days and i havent solved the problem yet
i will tell the problem in detail

My Server Code in PHP is as Follows:


<?php
require_once 'SOAP/Server.php';

// Your class
class HelloServer {
var $__dispatch_map = array();

function HelloServer() {
// Define the signature of the dispatch map
$this->__dispatch_map['sayHello'] =
array('in' => array('inputString' => 'string'),
'out' => array('outputString' => 'string'),
);

}

// Required function by SOAP_Server
function __dispatch($methodname) {
if (isset($this->__dispatch_map[$methodname]))
return $this->__dispatch_map[$methodname];
return NULL;
}

// Your function
function sayHello($inputString)
{
return 'Hello '.$inputString;
}
}

// Fire up PEAR::SOAP_Server
$server = new SOAP_Server;

// Fire up your class
$helloServer = new HelloServer();

// Add your object to SOAP server (note namespace)
$server->addObjectMap($helloServer,'urn:HelloServer');

// Handle SOAP requests coming is as POST data
if (isset($_SERVER['REQUEST_METHOD']) &&
$_SERVER['REQUEST_METHOD']=='POST') {
$server->service($HTTP_RAW_POST_DATA);
} else {
// Deal with WSDL / Disco here
require_once 'SOAP/Disco.php';

// Create the Disco server
$disco = new SOAP_DISCO_Server($server,'HelloServer');
header("Content-type: text/xml");
if (isset($_SERVER['QUERY_STRING']) &&
strcasecmp($_SERVER['QUERY_STRING'],'wsdl')==0) {
echo $disco->getWSDL(); // if we're talking http://www.example.com/index.php?wsdl
} else {
echo $disco->getDISCO();
}
exit;
}
?>



Now this program runs fine and produces a WSDL file this webservice i am calling in java.


The WSDL file is as follows:


<?xml version="1.0" ?>
- <definitions name="HelloServer" targetNamespace="urn:HelloServer" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="urn:HelloServer" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns="http://schemas.xmlsoap.org/wsdl/">
<types xmlns="http://schemas.xmlsoap.org/wsdl/" />
- <message name="sayHelloRequest">
<part name="inputString" type="xsd:string" />
</message>
- <message name="sayHelloResponse">
<part name="outputString" type="xsd:string" />
</message>
- <portType name="HelloServerPort">
- <operation name="sayHello">
<input message="tns:sayHelloRequest" />
<output message="tns:sayHelloResponse" />
</operation>
</portType>
- <binding name="HelloServerBinding" type="tns:HelloServerPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <operation name="sayHello">
<soap:operation soapAction="urn:HelloServer#HelloServer#sayHello" />
- <input>
<soap:body use="encoded" namespace="urn:HelloServer" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
- <output>
<soap:body use="encoded" namespace="urn:HelloServer" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
- <service name="HelloServerService">
<documentation />
- <port name="HelloServerPort" binding="tns:HelloServerBinding">
<soap:address location="http://localhost/PhpPrograms/server.php" />
</port>
</service>
</definitions>



with Client code in JAVA is as follows:

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;
import java.io.*;

public class Client2
{

public static void main(String[] args)
{
try
{
String endpoint = "http://localhost/PhpPrograms/server.php?wsdl";
Service service = new Service();
Call call = (Call) service.createCall();

call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName("http://soapinterop.org/", "sayHello"));
String ret = (String) call.invoke(new Object[]{"Ravindranath"});

System.out.println(ret);
}
catch (Exception e)
{
System.err.println(e.toString());
}
}
}


this code generates an error when calling the webservice, i know it is due to incompatible data types that i am calling from client code. how to make working the client code. please reply me as soon as possible.

The Error Generated is as follows:

java.net.SocketException: Connection reset

I am using eclipse 3.3(europa) i have configured the system and installed phpeclipse it works fine. building php webservice and client works fine but cross platform calling of web service i am not able to know.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Web Services All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement