Hello all:
I am having a problem with getting a web service to work. I am hosting the service on powweb. I found a basic script that takes two integers, adds them together, and returns the answer. Very simple right? Well, when I try to hit the web service, it returns a 500 error. I have attached an error screenshot and here is the code for the service followed by the wsdl(created by putting ?wsdl at the end of the url).
Can anyone see what I am doing wrong?
Thanks,
-Jason
<?php
error_reporting(E_ALL ^ E_NOTICE);
require_once 'SOAP/Server.php';
class ServiceClass {
var $__dispatch_map = array();
function ServiceClass() {
$this->__dispatch_map['add'] = array(
'in' => array('a' => 'int', 'b' => 'int'),
'out' => array('c' => 'int')
);
}
function __dispatch($method) {
if (isset($this->__dispatch_map[$method])) {
return $this->__dispatch_map[$method];
} else {
return null;
}
}
//HERE IS THE FUNCTION FOR THE SERVICE
function add($a, $b) {
$c = $a + $b;
return $c;
}
}
$soap = new SOAP_Server;
$service = new ServiceClass();
$soap->addObjectMap($service, 'urn:ServiceClass');
if (isset($_SERVER['REQUEST_METHOD']) &&
$_SERVER['REQUEST_METHOD'] == 'POST')
{
$soap->service($HTTP_RAW_POST_DATA);
}
else
{
require_once 'SOAP/Disco.php';
$disco = new SOAP_DISCO_Server($soap,'DiscoServer');
if (isset($_SERVER['QUERY_STRING']) &&
strpos($_SERVER['QUERY_STRING'], 'wsdl') === 0)
{
header('Content-type: text/xml');
echo $disco->getWSDL();
}
}
?>
WSDL:
<?xml version="1.0" ?>
- <definitions name="DiscoServer" targetNamespace="urn:DiscoServer" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="urn:DiscoServer" 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="addRequest">
<part name="a" type="xsd:int" />
<part name="b" type="xsd:int" />
</message>
- <message name="addResponse">
<part name="c" type="xsd:int" />
</message>
- <portType name="DiscoServerPort">
- <operation name="add">
<input message="tns:addRequest" />
<output message="tns:addResponse" />
</operation>
</portType>
- <binding name="DiscoServerBinding" type="tns:DiscoServerPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <operation name="add">
<soap:operation soapAction="urn:ServiceClass#ServiceClass#add" />
- <input>
<soap:body use="encoded" namespace="urn:ServiceClass" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
- <output>
<soap:body use="encoded" namespace="urn:ServiceClass" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
- <service name="DiscoServerService">
<documentation />
- <port name="DiscoServerPort" binding="tns:DiscoServerBinding">
<soap:address location="http://www.myserver.com/soaptest/add.php" />
</port>
</service>
</definitions>