douaoren4402 2013-06-24 14:27
浏览 26
已采纳

从PHP客户端向asp.net webservice发布一个int总是0

Hi I seem have created a SOAP webservice using asp.net , and tested it using an PHP client to get data.And it seems for getting data the service works.

THe problem appears when I try to post the data.It seems that the server always recieve the value 0.Here is my asp.net web service code:

public void DeleteBook(int categoryId)
    {
        using (var conn = new OdbcConnection(connectionString))
        {
            conn.Open();
            using (var command = new OdbcCommand())
            {
                command.Parameters.Add(new OdbcParameter("@CategoryId", categoryId));
                command.CommandText = "DELETE FROM Books WHERE CategoryId = @CategoryId";
                command.ExecuteNonQuery();
            }
        }
    }

And here is my PHP Soap client code:

  $client = new SoapClient($url);
  if(isset($_POST["id"])){
            $id = $_POST["id"];
            echo $id;
            $client->DeleteBook($id);
   }

I debugged the service and it seems the DeleteBook method get's hit but the problem is that the categoryId is 0.

What am I doing wrong?

  • 写回答

2条回答 默认 最新

  • dssu33392 2013-06-24 15:09
    关注

    Hi I managed to solve this problem by actualy sending the parameter as an array.This is what I have done and it worked:

    if(isset($_POST["id"])){
            $id = $_POST["id"];
            $obj = array("categoryId" => $id);
            $client->DeleteBook($obj);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失