Jump to content

SOAP Server how to?

- - - - -

  • Please log in to reply
1 reply to this topic

#1
Hamed

Hamed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 276 posts
Hello,
I want to make SOAP server.
I make my WSDL file and php file.
but i get empty file..
<?php

include("./MySoapClass.php");
$server = new SoapServer("./bank.wsdl");
$server->setClass('BankSOAP');
  $functions = $server->getFunctions();
  foreach($functions as $func) {
    echo $func . "\n";
  }
$server->handle();
?>

bank.wsdl
<?xml version='1.0' encoding='UTF-8'?>
<definitions name="OnLineBankPayment" targetNamespace="urn:OnLineBankPayment" xmlns:typens="urn:OnLineBankPayment" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"><message name="checkPayment"><part name="tid" type="xsd:anyType"></part></message><message name="checkPaymentResponse"></message><message name="getTran"><part name="username" type="xsd:anyType"></part><part name="password" type="xsd:anyType"></part><part name="callBackURL" type="xsd:anyType"></part><part name="price" type="xsd:anyType"></part></message><message name="getTranResponse"></message><message name="reversePayment"><part name="tid1" type="xsd:anyType"></part></message><message name="reversePaymentResponse"></message><portType name="BankSOAPPortType"><operation name="checkPayment"><input message="typens:checkPayment"></input><output message="typens:checkPaymentResponse"></output></operation><operation name="getTran"><input message="typens:getTran"></input><output message="typens:getTranResponse"></output></operation><operation name="reversePayment"><input message="typens:reversePayment"></input><output message="typens:reversePaymentResponse"></output></operation></portType><binding name="BankSOAPBinding" type="typens:BankSOAPPortType"><soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"></soap:binding><operation name="checkPayment"><soap:operation soapAction="urn:BankSOAPAction"></soap:operation><input><soap:body namespace="urn:OnLineBankPayment" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"></soap:body></input><output><soap:body namespace="urn:OnLineBankPayment" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"></soap:body></output></operation><operation name="getTran"><soap:operation soapAction="urn:BankSOAPAction"></soap:operation><input><soap:body namespace="urn:OnLineBankPayment" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"></soap:body></input><output><soap:body namespace="urn:OnLineBankPayment" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"></soap:body></output></operation><operation name="reversePayment"><soap:operation soapAction="urn:BankSOAPAction"></soap:operation><input><soap:body namespace="urn:OnLineBankPayment" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"></soap:body></input><output><soap:body namespace="urn:OnLineBankPayment" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"></soap:body></output></operation></binding><service name="OnLineBankPaymentService"><port name="BankSOAPPort" binding="typens:BankSOAPBinding"><soap:address location="http://127.0.0.1"></soap:address></port></service></definitions>
class:
<?php
class BankSOAP {
    public function getTran($username, $password, $callBackURL, $price) {
        $query = mysql_query("SELECT * FROM `shops` WHERE shopUserName='$username' AND shopPassword='$password' LIMIT 1");
        if (mysql_num_rows($query) == 1) {
            mysql_query("INSERT INTO `tran` (`tid` ,`s` ,`cUserName` ,`UserName` ,`callBackURL` ,`price`)VALUES (NULL , '1', '', '$username', '$callBackURL', '$price');");
            $tid = mysql_insert_id();
            return array("tid"=>$tid,"s"=>1);
        } else {
            return 0;
        }
    }
    public function checkPayment($tid) {
        $query = mysql_query("SELECT * FROM `tran` WHERE tid='$tid' LIMIT 1");
        $row = mysql_fetch_array($query);
        $s = $row['s'];
        if ($s == 2)
        {
            return 2;
        } else {
            return 3;
        }
    }
    public function reversePayment($tid) {
        $query = mysql_query("SELECT * FROM `tran` WHERE tid='$tid' LIMIT 1");
        $row = mysql_fetch_array($query);
        $s = $row['s'];
        $UserName = $row['UserName'];
        $cUserName = $row['cUserName'];
        $price = $row['price'];
        if($s == 2) {
            $query2 = mysql_query("SELECT * FROM `customer` WHERE cUserName='$cUserName'");
            $query3 = mysql_query("SELECT * FROM `shops` WHERE UserName='$UserName'");
            $row2 = mysql_fetch_array($query2);
            $row3 = mysql_fetch_array($query3);
            $ccash = $row2['cash'] + $price;
            $scash = $row3['cash'] - $price;
            mysql_query("UPDATE `tran` SET `s` = '4' WHERE `tran`.`tid` =$tid;");
            return 4;
        } else {
            return 5;
        }
    }
}
?>

Attached Files



#2
Hamed

Hamed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 276 posts
Sorry I can not upload my WSDL file.
please help me it is important for me.

Attached Files






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users