Hallo,
ich habe ein Problem bei der Konstruktion eines Amazon_FWSOutbound_Model_CreateFulfillmentOrder Objektes und sehe den Fehler nicht. Die Daten für das Objekt kommen von einem Webservice Client:
Der Server kann daraus jedoch nicht das gewünschte Objekt erstellen. $data ist hierbei der eingelesene String des Clients:
Der Fehler wird in am Ende bei $request = ... geworfen. Ich vermute das Problem besteht in der for Schleife und der Auswertung des Strings ($data). Vielleicht sieht jemand von Euch wo der Fehler ist.
Danke schon mal im voraus.
ich habe ein Problem bei der Konstruktion eines Amazon_FWSOutbound_Model_CreateFulfillmentOrder Objektes und sehe den Fehler nicht. Die Daten für das Objekt kommen von einem Webservice Client:
PHP-Code:
http://localhost/Amazon/mockWebService.php?Action=CreateFulfillmentOrder&MerchantFulfillmentOrderId=2&DisplayableOrderId=2&
DisplayableOrderDateTime=2010-10-27T16:16:15+02:00&DisplayableOrderComment=Danke_fuer_Ihre_Bestellung&ShippingSpeedCategory=Standard&
DestinationAddress.Name=Berthold_Heisterkamp&DestinationAddress.Line1=Sesamstrasse_33&DestinationAddress.Line2=&DestinationAddress.Line3=&
DestinationAddress.City=Koeln&DestinationAddress.StateOrProvinceCode=Nordrhein-Westfalen&DestinationAddress.CountryCode=DE&
DestinationAddress.PostalCode=50441&DestinationAddress.PhoneNumber=02227-555&Item.1.MerchantSKU=26&Item.1.MerchantFulfillmentOrderItemId=2&
Item.1.Quantity=2&Item.1.GiftMessage=&Item.1.DisplayableComment=&Item.2.MerchantSKU=25&Item.2.MerchantFulfillmentOrderItemId=3&
Item.2.Quantity=1&Item.2.GiftMessage=&Item.2.DisplayableComment=
PHP-Code:
case 'CreateFulfillmentOrder':
//OrderItem buildup
$orderItems = array();
$arrayKeys = array_keys($data);
$arrayKeySize = count($arrayKeys);
for ($i=0; $i<$arrayKeySize; $i++){
$v = $arrayKeys[$i];
$number = $i+1;
if(containsSubstring($v, 'Item.')){
require_once ('Amazon/FWSOutbound/Model/CreateFulfillmentOrderItem.php');
$CreateFulfillmentOrderItem = new Amazon_FWSOutbound_Model_CreateFulfillmentOrderItem();
$CreateFulfillmentOrderItem->setMerchantSKU($data['Item' . '.' . $number . '.' . 'MerchantSKU']);
$CreateFulfillmentOrderItem->setMerchantFulfillmentOrderItemId($data['Item' . '.' . $number . '.' . 'MerchantFulfillmentOrderItemId']);
$CreateFulfillmentOrderItem->setQuantity($data['Item' . '.' . $number . '.' . 'Quantity']);
$CreateFulfillmentOrderItem->setGiftMessage($data['Item' . '.' . $number . '.' . 'MerchantFulfillmentOrderItemId']);
$CreateFulfillmentOrderItem->setDisplayableComment($data['Item' . '.' . $number . '.' . 'Quantity']);
$orderItems[$i] = $CreateFulfillmentOrderItem;
}
}
//CreateFulfillmentOrder request
require_once ('Amazon/FWSOutbound/Model/CreateFulfillmentOrder.php');
$requestOrder = new Amazon_FWSOutbound_Model_CreateFulfillmentOrder();
$requestOrder->setMerchantFulfillmentOrderId($data['MerchantFulfillmentOrderId']);
$requestOrder->setDisplayableOrderId($data['DisplayableOrderId']);
$requestOrder->setDisplayableOrderDateTime($data['DisplayableOrderDateTime']);
$requestOrder->setDisplayableOrderComment($data['DisplayableOrderComment']);
$requestOrder->setShippingSpeedCategory($data['ShippingSpeedCategory']);
//Address buildup
for ($i=0; $i<$arrayKeySize; $i++){
$v = $arrayKeys[$i];
if(containsSubstring($v, 'DestinationAddress.')){
require_once ('Amazon/FWSOutbound/Model/Address.php');
$Address = new Amazon_FWSOutbound_Model_Address();
$Address->setName($data['DestinationAddress' . '.' . 'Name']);
$Address->setLine1($data['DestinationAddress' . '.' . 'Line1']);
$Address->setLine2($data['DestinationAddress' . '.' . 'Line2']);
$Address->setCity($data['DestinationAddress' . '.' . 'City']);
$Address->setStateOrProvinceCode($data['DestinationAddress' . '.' . 'StateOrProvinceCode']);
$Address->setCountryCode($data['DestinationAddress' . '.' . 'CountryCode']);
$Address->setPostalCode($data['DestinationAddress' . '.' . 'PostalCode']);
$Address->setPhoneNumber($data['DestinationAddress' . '.' . 'PhoneNumber']);
$requestOrder->setDestinationAddress($Address);
}
}
$requestOrder->setItem($orderItems);
require_once ('Amazon/FWSOutbound/Model/CreateFulfillmentOrder.php');
$request = new Amazon_FWSOutbound_Model_CreateFulfillmentOrder($requestOrder);
$ret = $serv->CreateFulfillmentOrder($request);
break;
PHP-Code:
function containsSubstring($initialString, $subString){
if(!is_string($initialString)){
return false;
}
if(strpos($initialString, $subString) !== false){
return true;
}
return false;
}
Danke schon mal im voraus.
Kommentar