通过PHP向从C#生成的WSDL发出SOAP请求,在语法方面遇到困难

通过PHP向从C#生成的WSDL发出SOAP请求,在语法方面遇到困难,c#,php,soap,wsdl,C#,Php,Soap,Wsdl,我有一个用C语言编写的web服务。我从PHP调用这个web服务的方法。所有期望原始参数的方法都非常有效。不过,我在尝试调用更复杂的方法时收到异常 这是我的简历: 我收到一个例外: SOAP-ERROR:编码:对象没有“选项”属性 谁能给我指一下正确的方向吗?或者让我知道我正在尝试的东西在技术上是否不可能 谢谢 哦,还有,这是一个C#测试用例,它可以工作: private readonly ComponentSearchServicesSoapClient ComponentSearchServi

我有一个用C语言编写的web服务。我从PHP调用这个web服务的方法。所有期望原始参数的方法都非常有效。不过,我在尝试调用更复杂的方法时收到异常

这是我的简历:

我收到一个例外:

SOAP-ERROR:编码:对象没有“选项”属性

谁能给我指一下正确的方向吗?或者让我知道我正在尝试的东西在技术上是否不可能

谢谢

哦,还有,这是一个C#测试用例,它可以工作:

private readonly ComponentSearchServicesSoapClient ComponentSearchServices = new ComponentSearchServicesSoapClient();

[Test]
public void TestSearchBarcode()
{
    AttributeFilter filter = new AttributeFilter
    {
        Attribute = -2,
        Comparison = SearchComparison.Equals,
        Value = "110001"
    };

    DataSet dataset = ComponentSearchServices.Search(new[] { filter }, "Administrator", null, ComponentSearchOptions.None, false, false);

    if (dataset.Tables.Count == 0 || dataset.Tables[0].Rows.Count != 1)
    {
        throw new Exception("Failed to properly search");
    }
}

解决方案由两部分组成

进行调用的正确语法为:

$search = $soapClient->Search(array("filters" => array("AttributeFilter" => array('Attribute' => 310, 'Comparison' => 'Equals', 'Value' => 'Peering LAN')), 'username' => 'Administrator', 'displayedAttributes' => array(310), 'options' => 'None', 'includeFlags' => true, 'includeIcons' => true));
另一个问题是AttributeFilter类希望属性“Value”的类型为“object”。将“Value”更改为“string”类型删除了正在发生的序列化异常

$filters = array("filter" => (object)array("AttributeFilter" => (object)array("Attribute" => -2, "SearchComparison" => "Equals", "Value" => "110001")));
$search = $soapClient->Search($filters , "Administrator", NULL, "None", true, true);
private readonly ComponentSearchServicesSoapClient ComponentSearchServices = new ComponentSearchServicesSoapClient();

[Test]
public void TestSearchBarcode()
{
    AttributeFilter filter = new AttributeFilter
    {
        Attribute = -2,
        Comparison = SearchComparison.Equals,
        Value = "110001"
    };

    DataSet dataset = ComponentSearchServices.Search(new[] { filter }, "Administrator", null, ComponentSearchOptions.None, false, false);

    if (dataset.Tables.Count == 0 || dataset.Tables[0].Rows.Count != 1)
    {
        throw new Exception("Failed to properly search");
    }
}
$search = $soapClient->Search(array("filters" => array("AttributeFilter" => array('Attribute' => 310, 'Comparison' => 'Equals', 'Value' => 'Peering LAN')), 'username' => 'Administrator', 'displayedAttributes' => array(310), 'options' => 'None', 'includeFlags' => true, 'includeIcons' => true));