PHP100 2019-03-27
代码如下:
<?php class person { public function say() { return("i'm speaking."); } public function run() { return("i'm running,don't disturb me please."); } } ?>
代码如下:
<?php include("person.class.php"); include("SoapDiscovery.class.php"); $disco = new SoapDiscovery('person','Person');//第一个参数是类名(生成的wsdl文件就是以它来命名的),即person类,第二个参数是服务的名字(这个可以随便写)。 $disco->getWSDL(); ?>
代码如下:
<?php include("person.class.php"); $objSoapServer = new SoapServer("person.wsdl");//person.wsdl是刚创建的wsdl文件 //$objSoapServer = new SoapServer("server.php?wsdl");//这样也行 $objSoapServer->setClass("person");//注册person类的所有方法 $objSoapServer->handle();//处理请求 ?>
代码如下:
<?php $client = new SoapClient("person.wsdl"); //$client = new SoapClient("server.php?wsdl");//这样也行 echo($client->say()); echo "<br />"; echo($client->run()); echo "<br />"; ?>
代码如下:
//return sprintf('%s%s%s%s%s%s', $headerWSDL, $portTypeWSDL, $bindingWSDL, $serviceWSDL, $messageWSDL, '</definitions>'); //生成wsdl文件,将上面的return注释 $fso = fopen($this->class_name . ".wsdl" , "w"); fwrite($fso, sprintf('%s%s%s%s%s%s', $headerWSDL, $portTypeWSDL, $bindingWSDL, $serviceWSDL, $messageWSDL, '</definitions>')); exit;
代码如下:
//比如我有个类:person,文件名为:person.class.php★,里面有两个方法,一个是say,一个是run。很简单。 <?php class person { public function say() { return("i'm speaking."); } public function run() { return("i'm running,don't disturb me please."); } } ?>
代码如下:
<?php include("person.class.php"); include("SoapDiscovery.class.php"); //第一个参数是类名(生成的wsdl文件就是以它来命名的),即person类,第二个参数是服务的名字(这个可以随便写)。 $disco = new SoapDiscovery('person','Person'); $disco->getWSDL(); ?>
代码如下:
<?php include("person.class.php"); $objSoapServer = new SoapServer("person.wsdl");//person.wsdl是刚创建的wsdl文件 //$objSoapServer = new SoapServer("server.php?wsdl");//这样也行 $objSoapServer->setClass("person");//注册person类的所有方法 $objSoapServer->handle();//处理请求 ?>
代码如下:
<?php $client = new SoapClient("person.wsdl"); //$client = new SoapClient("server.php?wsdl");//这样也行 echo($client->say()); echo "<br />"; echo($client->run()); echo "<br />"; ?>
代码如下:
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { sdaf.Solsoft_HelloWorld ddd = new sdaf.Solsoft_HelloWorld(); Label1.Text = ddd.say(); } }
<?php. if (!empty($_POST)) {. $data1 = $_POST["data1"];$data2 = $_POST["data2"];$fuhao = $_POST["fuh