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 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?