1

I'm trying to create the sales order shipment partially in magento with the following request [1]. I get "SOAP-ERROR: Encoding: Violation of encoding rules". Can anyone help me to resolve this issue?

[1]

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:salesOrderShipmentCreate>
         <sessionId>xxxxxxxxxxxxxxxxxxxxxx</sessionId>
         <orderIncrementId>200006672</orderIncrementId>
         <itemsQty><orderItemIdQty><order_item_id>AG0102019</order_item_id><qty>1.0</qty></orderItemIdQty></itemsQty>
         <comment>Testing</comment>
         <email>1</email>
      </urn:salesOrderShipmentCreate>
   </soapenv:Body>
</soapenv:Envelope>

Thanks in advance

2
  • i think you are missing some tags that why u are getting this error
    – BornCoder
    Commented Feb 1, 2017 at 4:49
  • Is the structure of 'itemsQty' element correct? When I pass this element only I get this error. <itemsQty><orderItemIdQty><order_item_id>AG0102019</order_item_id><qty>1.0</qty></orderItemIdQty></itemsQty> Commented Feb 1, 2017 at 6:59

2 Answers 2

1

Request Example SOAP V1

$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');

$session = $proxy->login('apiUser', 'apiKey');

$orderIncrementId = '200000006';
$orderItemId = 3;
$qty = 5;
$itemsQty = array(
    $orderItemId => $qty,
    );

$result = $proxy->call(
    $session,
    'order_shipment.create',
    array(
        $orderIncrementId,
        $itemsQty
    )
);

var_dump ($result);

Request Example SOAP V2

$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');

$itemsQty = array(
    array(
        'order_item_id' => 3,
        'qty' => 3
    ),
    array(
        'order_item_id' => 4,
        'qty' => 5
    ));

$result = $proxy->salesOrderShipmentCreate($sessionId, '200000006', $itemsQty, 'shipment comment');
var_dump($result);

See more details here

1
  • Thanks for the response, I already went through the doc. I'm not using the PHP client to send the request but need to send the request via SOAP UI with XML payload as I mentioned in the question. I hope this is the way to pass the 'itemsQty' element according to the documentation. But the back-end throws "Violation of encoding rules" exception in this situation. Commented Feb 1, 2017 at 5:08
1

The order_item_id is an integer type element and the passed value is string. So that the 'Violation of encoding rules' issue comes.

The request should be like this,

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:salesOrderShipmentCreate soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <sessionId>xxxxxxxxxxxxxxxxx</sessionId>
         <orderIncrementId>200006672</orderIncrementId>
         <itemsQty>
                <urn:orderItemIdQty>
                    <order_item_id>13066</order_item_id>
                    <qty>1.0</qty>
                </urn:orderItemIdQty>
            </itemsQty>
      </urn:salesOrderShipmentCreate>
   </soapenv:Body>
</soapenv:Envelope>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.