PHP soap web service asmx issue: SOAP-ERROR: Encoding: object has no

PHP soap web service asmx issue: SOAP-ERROR: Encoding: object has no

我正在尝试 post 数据到 .net 网络服务,但收到错误消息:"SOAP-ERROR: Encoding: object has no 'ActiveCust' property"。

这里是wsdl:

<s:element name="SubmitNewCustomerToB1">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Context" type="tns:B1Context"/>
<s:element minOccurs="0" maxOccurs="1" name="WebsiteName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Cust" type="tns:Customer"/>
<s:element minOccurs="1" maxOccurs="1" name="ActiveCust" type="s:boolean"/>
<s:element minOccurs="0" maxOccurs="1" name="CustomerCustomAttrs" type="tns:ArrayOfCustomAttribute"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="SubmitNewCustomerToB1Response">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="SubmitNewCustomerToB1Result" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>

<s:complexType name="B1Context">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="B1DBName" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="B1DefaultPriceListNumber" type="s:int"/>
<s:element minOccurs="0" maxOccurs="1" name="B1UKStandardVatCode" type="s:string"/>
</s:sequence>
</s:complexType>

<s:complexType name="Customer">
<s:complexContent mixed="false">
<s:extension base="tns:EntityObject">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="CardCode" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="WebPassword" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="EmailAddress" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Title" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="FirstName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Surname" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Telephone" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="WebID" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="VATNumber" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="FaxNumber" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Telephone2" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Organisation" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="MobilePhone" type="s:string"/>
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>

<s:complexType name="CustomAttribute">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="FieldName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="FieldValue" type="s:string"/>
</s:sequence>
</s:complexType>

这是我的代码:

error_reporting(E_ALL);

$Context =array(
        "B1DBName" => "Test",
        "B1DefaultPriceListNumber" => 1,
        "B1UKStandardVatCode" => "O1",
    );

$WebsiteName =array(
    "WebsiteName"=> "Tes webiste"
);

$Cust =array(
    "CardCode" => "",
    "WebPassword" => "",
    "EmailAddress" => "l@l.com",
    "Title" => "Mr",
    "FirstName" => "Luca",
    "Surname" => "Luchino",
    "Telephone" => "02094388",
    "WebID" => "1988",
    "VATNumber" => "",
    "FaxNumber" => "0209998",
    "Telephone2" => "",
    "Organisation" => "",
    "MobilePhone" => ""
);


$ActiveCust =array(
    "ActiveCust" => true
);

$CustomerCustomAttrs=array(
    $CustomAttribute=array(
        "FieldName" => "",
        "FieldValue" => ""
    )
);

//Associative array
$params = array(
    $Context,
    $WebsiteName,
    $Cust,
    $ActiveCust,
    $CustomerCustomAttrs
);

//var_dump($params);

try {
    $client = new SoapClient("http://my.asmx?wsdl");
    $result = $client->SubmitNewCustomerToB1($params);

    var_dump($result);

} 
catch (Exception $e) 
{
    echo "Error!<br />";
    echo $e -> getMessage ();
}

我得到的错误: SOAP-ERROR:编码:对象没有 'ActiveCust' 属性

有人可以帮助我吗? 非常感谢! 卢卡

关联数组的格式正确。 问题是最后一个可选数组 $CustomerCustomAttrs,我删除了它,Web 服务开始正常工作。

旧版本

//Associative array
$params = array(
    $Context,
    $WebsiteName,
    $Cust,
    $ActiveCust,
    $CustomerCustomAttrs
);

新版本

$params = array(
    'Context' => $Context,
    'WebsiteName' => $WebsiteName,
    'Cust' => $Cust,
    'ActiveCust' => $ActiveCust
);