проблемы с SOAP (PHP)
Код:
$client = new SoapClient("http://emexonline.com:3000/MaximaWS/service.wsdl", array("trace" => 1, "exceptions" => 1, 'soap_version' => SOAP_1_2));
Код:
$pl = array (
"UserName" => 'User',
"Password" => 'Password',
"SubCustomerId" => '0',
"CustomerId" => '0'
);
$pb[] = ( object ) array (
"MakeLogo" => 'MakeLogo',
"DetailNum" => 'DetailNum',
"PriceLogo" => 'PriceLogo',
"DestinationLogo" => 'CNTE',
"bitOnly" => true,
"bitquantity" => true,
"bitWait" => false,
"CustomerSubId" => '',
"DetailWeight" => '0.005',
"EmExWeight" => '0.005'
);
$place2cart = $client->InsertPartToBasket(array('Customer' => $pl, 'Array' => array('partstobasket' => $pb)));
"UserName" => 'User',
"Password" => 'Password',
"SubCustomerId" => '0',
"CustomerId" => '0'
);
$pb[] = ( object ) array (
"MakeLogo" => 'MakeLogo',
"DetailNum" => 'DetailNum',
"PriceLogo" => 'PriceLogo',
"DestinationLogo" => 'CNTE',
"bitOnly" => true,
"bitquantity" => true,
"bitWait" => false,
"CustomerSubId" => '',
"DetailWeight" => '0.005',
"EmExWeight" => '0.005'
);
$place2cart = $client->InsertPartToBasket(array('Customer' => $pl, 'Array' => array('partstobasket' => $pb)));
Полная версия скрипта в приложении
проблема решена, ошибка была в документации к сервису
С разбегу могу сказать одно: беда в кодировке. Нужно кодировать буквы в UTF-8. Это штандартно для передачи чего либо в XML и JSON.
Цитата: mfender
С разбегу могу сказать одно: беда в кодировке. Нужно кодировать буквы в UTF-8. Это штандартно для передачи чего либо в XML и JSON.
запрос отсылается как раз в utf8, Вы натолкнули меня на мысль и я попробовал изменить кодировку на windows-1251 (чем черт не шутит?!), но это не привело к нужному эффекту, ошибка осталась. Хочу добавить, что после выполнения функции "InsertPartToBasket" на сервер приходит DestinationLogo пустым (NULL), и сервер устанавливает значение по умолчанию "EMEW", но если применить функцию "UpdateBasketDetails" (функция правки внесенных данных) с тем же набором данных! то без проблем устанавливается нужное значение DestinationLogo, т.е. отправка проходит успешно.
высылаю трассировки запросов и ответов
var_dump массива на запрос InsertPartToBasket
Код:
Array
(
[Customer] => Array
(
[UserName] => Username
[Password] => Password
[SubCustomerId] => 0
[CustomerId] => 0
)
[Array] => Array
(
[partstobasket] => Array
(
[0] => stdClass Object
(
[CoeffMaxAgree] => 1.1
[UploadedPrice] => 10.74
[bitAgree] =>
[OnlyThisBrand] => 1
[Confirm] =>
[Delete] =>
[BasketId] =>
[MakeLogo] => SU
[DetailNum] => 92183AG00AJC
[PriceLogo] => EUSA
[Quantity] => 1
[DestinationLogo] => CNTE
[bitOnly] => 1
[bitquantity] => 1
[bitWait] =>
[Reference] => test
[CustomerSubId] =>
[DetailWeight] => 0.005
[EmExWeight] => 0.005
)
)
)
)
(
[Customer] => Array
(
[UserName] => Username
[Password] => Password
[SubCustomerId] => 0
[CustomerId] => 0
)
[Array] => Array
(
[partstobasket] => Array
(
[0] => stdClass Object
(
[CoeffMaxAgree] => 1.1
[UploadedPrice] => 10.74
[bitAgree] =>
[OnlyThisBrand] => 1
[Confirm] =>
[Delete] =>
[BasketId] =>
[MakeLogo] => SU
[DetailNum] => 92183AG00AJC
[PriceLogo] => EUSA
[Quantity] => 1
[DestinationLogo] => CNTE
[bitOnly] => 1
[bitquantity] => 1
[bitWait] =>
[Reference] => test
[CustomerSubId] =>
[DetailWeight] => 0.005
[EmExWeight] => 0.005
)
)
)
)
Код:
REQUEST:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://emexonline.com:3000/MaximaWS/"><env:Body><ns1:InsertPartToBasket><ns1:Customer><ns1:UserName>Username</ns1:UserName><ns1:Password>Password</ns1:Password><ns1:SubCustomerId>0</ns1:SubCustomerId><ns1:CustomerId>0</ns1:CustomerId></ns1:Customer><ns1:Array><ns1:partstobasket><ns1:CoeffMaxAgree>1.1</ns1:CoeffMaxAgree><ns1:UploadedPrice>10.74</ns1:UploadedPrice><ns1:bitAgree>false</ns1:bitAgree><ns1:OnlyThisBrand>true</ns1:OnlyThisBrand><ns1:Confirm>false</ns1:Confirm><ns1:Delete>false</ns1:Delete><ns1:BasketId>0</ns1:BasketId><ns1:MakeLogo>SU</ns1:MakeLogo><ns1:DetailNum>92183AG00AJC</ns1:DetailNum><ns1:PriceLogo>EUSA</ns1:PriceLogo><ns1:Quantity>1</ns1:Quantity><ns1:bitOnly>true</ns1:bitOnly><ns1:bitquantity>true</ns1:bitquantity><ns1:bitWait>false</ns1:bitWait><ns1:Reference>test</ns1:Reference><ns1:CustomerSubId>0</ns1:CustomerSubId><ns1:DetailWeight>0.005</ns1:DetailWeight><ns1:EmExWeight>0.005</ns1:EmExWeight></ns1:partstobasket></ns1:Array></ns1:InsertPartToBasket></env:Body></env:Envelope>
RESPONSE:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><InsertPartToBasketResponse xmlns="http://emexonline.com:3000/MaximaWS/"><InsertPartToBasketResult>1</InsertPartToBasketResult></InsertPartToBasketResponse></soap:Body></soap:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://emexonline.com:3000/MaximaWS/"><env:Body><ns1:InsertPartToBasket><ns1:Customer><ns1:UserName>Username</ns1:UserName><ns1:Password>Password</ns1:Password><ns1:SubCustomerId>0</ns1:SubCustomerId><ns1:CustomerId>0</ns1:CustomerId></ns1:Customer><ns1:Array><ns1:partstobasket><ns1:CoeffMaxAgree>1.1</ns1:CoeffMaxAgree><ns1:UploadedPrice>10.74</ns1:UploadedPrice><ns1:bitAgree>false</ns1:bitAgree><ns1:OnlyThisBrand>true</ns1:OnlyThisBrand><ns1:Confirm>false</ns1:Confirm><ns1:Delete>false</ns1:Delete><ns1:BasketId>0</ns1:BasketId><ns1:MakeLogo>SU</ns1:MakeLogo><ns1:DetailNum>92183AG00AJC</ns1:DetailNum><ns1:PriceLogo>EUSA</ns1:PriceLogo><ns1:Quantity>1</ns1:Quantity><ns1:bitOnly>true</ns1:bitOnly><ns1:bitquantity>true</ns1:bitquantity><ns1:bitWait>false</ns1:bitWait><ns1:Reference>test</ns1:Reference><ns1:CustomerSubId>0</ns1:CustomerSubId><ns1:DetailWeight>0.005</ns1:DetailWeight><ns1:EmExWeight>0.005</ns1:EmExWeight></ns1:partstobasket></ns1:Array></ns1:InsertPartToBasket></env:Body></env:Envelope>
RESPONSE:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><InsertPartToBasketResponse xmlns="http://emexonline.com:3000/MaximaWS/"><InsertPartToBasketResult>1</InsertPartToBasketResult></InsertPartToBasketResponse></soap:Body></soap:Envelope>
Код:
Array
(
[Customer] => Array
(
[UserName] => Username
[Password] => Password
[SubCustomerId] => 0
[CustomerId] => 0
)
[Array] => Array
(
[partstobasket] => Array
(
[0] => stdClass Object
(
[CoeffMaxAgree] => 1.1
[UploadedPrice] => 10.74
[Price] => 10.74
[bitConfirm] =>
[bitAgree] =>
[bitOnlyThisBrand] => 1
[Date_add] => 2013-11-01T18:04:00
[BasketId] => 5848094
[DestinationLogo] => CNTE
[Quantity] => 1
[bitOnlyThisNumber] => 1
[bitOnlyThisQuantity] => 1
[bitWait] =>
[DetailWeight] => 0.005
[EmExWeight] => 0.005
)
)
)
)
(
[Customer] => Array
(
[UserName] => Username
[Password] => Password
[SubCustomerId] => 0
[CustomerId] => 0
)
[Array] => Array
(
[partstobasket] => Array
(
[0] => stdClass Object
(
[CoeffMaxAgree] => 1.1
[UploadedPrice] => 10.74
[Price] => 10.74
[bitConfirm] =>
[bitAgree] =>
[bitOnlyThisBrand] => 1
[Date_add] => 2013-11-01T18:04:00
[BasketId] => 5848094
[DestinationLogo] => CNTE
[Quantity] => 1
[bitOnlyThisNumber] => 1
[bitOnlyThisQuantity] => 1
[bitWait] =>
[DetailWeight] => 0.005
[EmExWeight] => 0.005
)
)
)
)
Код:
REQUEST:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://emexonline.com:3000/MaximaWS/"><env:Body><ns1:UpdateBasketDetails><ns1:Customer><ns1:UserName>Username</ns1:UserName><ns1:Password>Password</ns1:Password><ns1:SubCustomerId>0</ns1:SubCustomerId><ns1:CustomerId>0</ns1:CustomerId></ns1:Customer><ns1:P><ns1:BasketDetails><ns1:UploadedPrice>10.74</ns1:UploadedPrice><ns1:CoeffMaxAgree>1.1</ns1:CoeffMaxAgree><ns1:Price>10.74</ns1:Price><ns1:bitConfirm>false</ns1:bitConfirm><ns1:bitAgree>false</ns1:bitAgree><ns1:bitOnlyThisBrand>true</ns1:bitOnlyThisBrand><ns1:Date_add>2013-11-01T18:04:00</ns1:Date_add><ns1:BasketId>5848094</ns1:BasketId><ns1:DestinationLogo>CNTE</ns1:DestinationLogo><ns1:Quantity>1</ns1:Quantity><ns1:bitOnlyThisNumber>true</ns1:bitOnlyThisNumber><ns1:bitOnlyThisQuantity>true</ns1:bitOnlyThisQuantity><ns1:bitWait>false</ns1:bitWait><ns1:DetailWeight>0.005</ns1:DetailWeight><ns1:EmExWeight>0.005</ns1:EmExWeight></ns1:BasketDetails></ns1:P></ns1:UpdateBasketDetails></env:Body></env:Envelope>
RESPONSE:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><UpdateBasketDetailsResponse xmlns="http://emexonline.com:3000/MaximaWS/"><UpdateBasketDetailsResult>1</UpdateBasketDetailsResult></UpdateBasketDetailsResponse></soap:Body></soap:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://emexonline.com:3000/MaximaWS/"><env:Body><ns1:UpdateBasketDetails><ns1:Customer><ns1:UserName>Username</ns1:UserName><ns1:Password>Password</ns1:Password><ns1:SubCustomerId>0</ns1:SubCustomerId><ns1:CustomerId>0</ns1:CustomerId></ns1:Customer><ns1:P><ns1:BasketDetails><ns1:UploadedPrice>10.74</ns1:UploadedPrice><ns1:CoeffMaxAgree>1.1</ns1:CoeffMaxAgree><ns1:Price>10.74</ns1:Price><ns1:bitConfirm>false</ns1:bitConfirm><ns1:bitAgree>false</ns1:bitAgree><ns1:bitOnlyThisBrand>true</ns1:bitOnlyThisBrand><ns1:Date_add>2013-11-01T18:04:00</ns1:Date_add><ns1:BasketId>5848094</ns1:BasketId><ns1:DestinationLogo>CNTE</ns1:DestinationLogo><ns1:Quantity>1</ns1:Quantity><ns1:bitOnlyThisNumber>true</ns1:bitOnlyThisNumber><ns1:bitOnlyThisQuantity>true</ns1:bitOnlyThisQuantity><ns1:bitWait>false</ns1:bitWait><ns1:DetailWeight>0.005</ns1:DetailWeight><ns1:EmExWeight>0.005</ns1:EmExWeight></ns1:BasketDetails></ns1:P></ns1:UpdateBasketDetails></env:Body></env:Envelope>
RESPONSE:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><UpdateBasketDetailsResponse xmlns="http://emexonline.com:3000/MaximaWS/"><UpdateBasketDetailsResult>1</UpdateBasketDetailsResult></UpdateBasketDetailsResponse></soap:Body></soap:Envelope>