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 求差集那个函数有问题,有无佬可以解决
  • ¥15 MATLAB动图问题
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名