Need help with a function

Hello,
I wanna create a simple webservice that sum two digits, that means when i send 2 , 4 to the function it returns 6.

Note: that my server support SOAP

post the code you have so far and we can try to help.

First you have to start with a server, and you could use the NuSOAP class (It’s somewhere lingering on the internet), to get started.

Rather than explaining in details, see the following example to add two numbers:

WSDL definition:
calculate.wsdl (http://www.w3schools.com/wsdl/wsdl_documents.asp)


<?xml version ='1.0' encoding ='UTF-8' ?>
<definitions name='NumCalculate'
  targetNamespace='http://example.org/NumCalculate'
  xmlns:tns=' http://example.org/NumCalculate '
  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='addNumRequest'>
  <part name='num1' type='xsd:int'/>
  <part name='num2' type='xsd:int'/>
</message>
<message name='addNumResponse'>
  <part name='Result' type='xsd:float'/>
</message>

<portType name='NumCalculatePortType'>
  <operation name='addNum'>
    <input message='tns:addNumRequest'/>
    <output message='tns:addNumResponse'/>
  </operation>
</portType>

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

<service name='NumCalculateService'>
  <port name='NumCalculatePort' binding='NumCalculateBinding'>
    <soap:address location='http://localhost/test/soap/example1/server.php'/>
  </port>
</service>
</definitions>

Please note the <soap:address location=‘http://localhost/test/soap/example1/server.php’/> is of my local server. Change this url to your server script.

Now your server script should be like this:
server.php


function addNum($num1, $num2) {
	return $num1 + $num2;
}

ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("calculate.wsdl");
$server->addFunction("addNum");
$server->handle();

See the PHP Manual for used functions and SOAP server library.

And finally you can call this service as a client:
client.php


$client = new SoapClient("calculate.wsdl");
echo $client->addNum(4, 2);

SOAP Client manual page.
Hope this will help you to jump start.