php中c#web服务中的参数列表


Parameter list in c # web services in php

我在web服务c#中用php传递参数列表时遇到问题。

c#中的Web服务如下:

[WebMethod ()]
public string IncluirOrcamento (List <ProdutosOrcamento> Products)
{
...
}

其中ProdutosAlcamento是c#中的一个类,以这种方式表示。。

public class ProdutosOrcamento
{
         public string ProductCode {get; sets;}
         public Nullable <double> quantity {get; sets;}
}

在php中这样做。。。

<? php
require_once ('/ lib / nusoap.php');
$ array = array ("Product" => array ("ProdutosOrcamento" => array (
'ProductCode' => '44 ',
'quantity' => '2 ')
"ProdutosOrcamento" => array (
'ProductCode' => '55 '​​,
'quantity' => '13 ')));
/ / print_r ($ array);
$ wsdl = "http://localhost:33328/KasviService.asmx?WSDL";
$ function = "IncluirOrcamento";
$ client = new nusoap_client ("http://localhost:33328/KasviService.asmx?WSDL", array ('location' => 'http://localhost:33328/KasviService.asmx?WSDL'));
$ result = $ client-> call ("IncluirOrcamento", $ array);
if ($ client-> fault) {
print_r ($ result);
else {}
     $ err = $ client-> getError ();
if ($ err) {
echo 'Error <h2> </ h2> <pre>'. $ err. '</ pre>';
     else {}
print_r ($ result);
     }
}
?>

我传递了一个对象数组,但我的问题是只考虑数组中的最后一个对象,并且我无法构建一个包含大量对象的列表。有人知道如何在C#的php web服务中传递对象列表吗?

首先,我假设您的代码中有多余的空间&数据只是复制/粘贴格式问题,因为在编写时,您的代码会生成致命错误。

假设额外的空格是唯一的复制/粘贴问题,问题是您通过重新使用相同的密钥来覆盖数组数据:

$array = array(
    "Product" => array(
        "ProdutosOrcamento" => array( // key:  ProdutosOrcamento
            'ProductCode' => '44 ',
            'quantity' => '2 ')  // You're also missing a comma here...
        "ProdutosOrcamento" => array( // key:  ProdutosOrcamento again!
            'ProductCode' => '55 '​​,
            'quantity' => '13 ')
    )
);

因此,表示ProductCode 55的数组正在覆盖表示ProductCode 44的数组。