hayi123 2013-11-02 13:36 采纳率: 33.3%
浏览 3232

求解用php做一个web service的相关程序??不知道哪里出问题了?谢谢!!!

<?php

class soap
{
private $tel;
private $num;
public function Book($tel,$num)
{
file_put_contents("d:/mylog.log",$tel,FILE_APPEND);
$this->tel=$tel;
$this->num=$num;//????

    $conn=mysql_connect("localhost","root","");
    if(!$conn) {
        die("连接数据库失败".mysql_error());
    }
    mysql_query("set names utf8",$conn)or die(mysql_errno());
    mysql_select_db("myorder",$conn) or die(mysql_errno());

    $sql="insert into mytable (tel,num) values('$tel','$num')";
    $res=mysql_query($sql,$conn)or die(mysql_error());
    if(!$res)
    {
     //die("操作失败".mysql_error());
     return false;
    }
    return TRUE;
    mysql_close($conn);
}

}
?>
服务端:
<?php
ini_set("soap.wsdl_cache_enabled", "0");
require_once 'order.php';
$ser=new SoapServer('soap.wsdl',array('soap_version' => SOAP_1_2)); //创建SoapServer对象
$ser->setClass("soap");
$ser->handle();
?>

客户端:

<?php
try{
ini_set("soap.wsdl_cache_enabled", "0");
$tel=$_POST['tel'];
$num=$_POST['num'];
$client=new SoapClient("soap.wsdl");
//echo $tel;
//$tel="13245678900";
//$num="22";
echo $tel;
$result=$client->Book("$tel","$num");//这句有问题

if($result) {
    echo "注册成功!"; 
} else echo "注册失败!";

}catch (SoapFault $e)
{
echo $e->getMessage();
}catch (Exception $e)
{
echo $e->getMessage();
}
?>
以及WSDL文件:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

wsdl:types


xsd:complexType
xsd:sequence

/xsd:sequence
/xsd:complexType
/xsd:element

xsd:complexType
xsd:sequence

/xsd:sequence
/xsd:complexType
/xsd:element
/xsd:schema
/wsdl:types


/wsdl:part
/wsdl:message


/wsdl:message




/wsdl:operation
/wsdl:portType

transport="http://schemas.xmlsoap.org/soap/http" />


wsdl:input

/wsdl:input
wsdl:output

/wsdl:output
/wsdl:operation
/wsdl:binding



/wsdl:port
/wsdl:service
/wsdl:definitions

  • 写回答

1条回答 默认 最新

  • hayi123 2013-11-03 11:22
    关注

    有没有哪位大神帮忙看一下,小弟在此谢过呀!

    评论

报告相同问题?

悬赏问题

  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误