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
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题