Php комплексный тип проблемы с мылом: SOAP-ERROR: Кодировка: у объекта нет свойстваобъекта

Я должен вызвать веб-сервис .net с помощью Php.
Все хорошо работает за один звонок в веб-сервис. при попытке отправить более одной записи я получаю сообщение об ошибке:

SOAP-ERROR: Кодировка: объект не имеет свойства ‘ActiveCust’ .объект (mysqli_result) # 2 (5) {[«current_field»] => int (0) [«field_count»] => int (21) [«lengths»] = > NULL [«num_rows»] => int (2) [«type»] => int (0)}

Это 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>

Это код, который хорошо работает для одного клиента:

$Context =array(
"B1DBName" => "TestDB",
"B1DefaultPriceListNumber" => "1",
"B1UKStandardVatCode" => "O1",
);$WebsiteName =array(
"WebsiteName"=> "Tes webiste");$Cust =array(
"CardCode" => "",
"WebPassword" => "",
"EmailAddress" => "l@l.com",
"Title" => "Mr",
"FirstName" => "Alexander",
"Surname" => "Calder",
"Telephone" => "02094388",
"WebID" => "1990",
"VATNumber" => "",
"FaxNumber" => "0209998",
"Telephone2" => "",
"Organisation" => "",
"MobilePhone" => "");$ActiveCust =array(
"ActiveCust" => "true");//Parameters must be an associative array
$params = array(
'Context' => $Context,
'WebsiteName' => $WebsiteName,
'Cust' => $Cust,
'ActiveCust' => $ActiveCust
);

var_dump($params);

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

var_dump($result);

echo "<br><br> VALUE:" . $result->SubmitNewCustomerToB1Result;

}
catch (Exception $e)
{
echo "Error!<br />";
echo $e -> getMessage ();
var_dump($result);
echo "<br><br> VALUE:" . $result->SubmitNewCustomerToB1Result;
}

Вот код, который я использую для отправки более одного клиента на веб-сервер

include("include/dbConn.php");

$CustArray = array();

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

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

$strSql="SELECT * FROM custom_clients_insert_view where b_lastname in('Hawkins','James')";
$result = mysqli_query($conn,$strSql) or die("MySQL error: " . mysqli_error($conn) . "<hr>\nQuery: $strSql");
while($row = mysqli_fetch_array($result))
{
$Cust =array(
"CardCode" => "",
"WebPassword" => "",
"EmailAddress" => $row['email'],
"Title" => "",
"FirstName" => $row['b_firstname'],
"Surname" => $row['b_lastname'],
"Telephone" => $row['b_phone'],
"WebID" => $row['user_id'],
"VATNumber" => "",
"FaxNumber" => $row['fax'],
"Telephone2" => "",
"Organisation" => "",
"MobilePhone" => "");

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

/*here I create the sequence by pushing the $params array in the parent array $CustArray*/
array_push($CustArray, $params);
}

var_dump($CustArray);

try
{
$client = new SoapClient("http://ipaddress/b1synccontext.asmx?wsdl");
$result = $client->SubmitNewCustomerToB1($CustArray);
var_dump($result);
echo "<br><br> VALUE:" . $result->SubmitNewCustomerToB1Result;
}
catch (Exception $e)
{
echo "Error!<br />";
echo $e -> getMessage ();
var_dump($result);
echo "<br><br> VALUE:" . $result->SubmitNewCustomerToB1Result;
}

Здесь массив я отправляю

array(2) {
[0]=>
array(4) {
["Context"]=>
array(3) {
["B1DBName"]=>
string(11) "SGL_WebTest"["B1DefaultPriceListNumber"]=>
string(1) "1"["B1UKStandardVatCode"]=>
string(2) "O1"}
["WebsiteName"]=>
array(1) {
["WebsiteName"]=>
string(12) "Test webiste"}
["Cust"]=>
array(13) {
["CardCode"]=>
string(0) ""["WebPassword"]=>
string(0) ""["EmailAddress"]=>
string(13) "mel@mel.co.uk"["Title"]=>
string(0) ""["FirstName"]=>
string(7) "Melanie"["Surname"]=>
string(7) "Hawkins"["Telephone"]=>
string(13) "020 477448844"["WebID"]=>
string(5) "28881"["VATNumber"]=>
string(0) ""["FaxNumber"]=>
string(0) ""["Telephone2"]=>
string(0) ""["Organisation"]=>
string(0) ""["MobilePhone"]=>
string(0) ""}
["ActiveCust"]=>
array(1) {
["ActiveCust"]=>
string(4) "true"}
}
[1]=>
array(4) {
["Context"]=>
array(3) {
["B1DBName"]=>
string(11) "SGL_WebTest"["B1DefaultPriceListNumber"]=>
string(1) "1"["B1UKStandardVatCode"]=>
string(2) "O1"}
["WebsiteName"]=>
array(1) {
["WebsiteName"]=>
string(12) "Test webiste"}
["Cust"]=>
array(13) {
["CardCode"]=>
string(0) ""["WebPassword"]=>
string(0) ""["EmailAddress"]=>
string(19) "jessica@jessica.com"["Title"]=>
string(0) ""["FirstName"]=>
string(7) "Jessica"["Surname"]=>
string(5) "James"["Telephone"]=>
string(11) "020 4764777"["WebID"]=>
string(5) "28882"["VATNumber"]=>
string(0) ""["FaxNumber"]=>
string(0) ""["Telephone2"]=>
string(0) ""["Organisation"]=>
string(0) ""["MobilePhone"]=>
string(0) ""}
["ActiveCust"]=>
array(1) {
["ActiveCust"]=>
string(4) "true"}
}
}
Error!<br />SOAP-ERROR: Encoding: object has no 'ActiveCust' propertyobject(mysqli_result)#2 (5) {
["current_field"]=>
int(0)
["field_count"]=>
int(21)
["lengths"]=>
NULL
["num_rows"]=>
int(2)
["type"]=>
int(0)
}

1

Решение

Клиент должен быть отправлен один раз, а не в коллекции.

0

Другие решения

Других решений пока нет …