0

我正在尝试创建一个 SOAP 请求,该请求部分具有以下内容:

<com:locale language="?" country="?">
                     <com:descriptions>

                        <com:description type="?">This is a description</com:description>
                     </com:descriptions>
                     <com:marketingDescription>This is a marketing des</com:marketingDescription>

我可以使用以下内容很好地添加属性:

function buildTask($db, $id=1) {
$task = array(
    'id' => $id++,
    'insertCustomProduct' => array(
                                    'manufacturerId' => "1234567",
                                    'manufacturerPartNo' => "ABC12345",

                                    'categoryId' => 10000000,
                                    'categoryType' => 'default',  
                                    'skus' => array(
                                                    'sku' => array(
                                                                    'type' => 'Internal',
                                                                    'number' => "123456ff",
                                                                    ),
                                                    ),
                                    'locales' => array(
                                                    'locale' => array(
                                                                    'language' => 'EN',
                                                                    'country' => 'US',
                                                                    'descriptions' => array(
                                                                                            'description' => array("type"=>1,
                                                                                                                    "CustomDescription"=>"This is a test")
                                                                                      ),
          'marketingDescription' => "This is the test Marketing Text",
        ),
      ),
    )
  );

我在传递非属性值时遇到问题,例如实际描述和营销文本

我将不胜感激任何帮助

4

1 回答 1

0

记录在案的“_”数组键应该为您提供部分 XML 的值(在此处的评论中找到并在此处提及 SO )。在您的示例中,这些内容 - 当然未经测试:

function buildTask($db, $id=1) {
$task = array(
    'id' => $id++,
    'insertCustomProduct' => array(
        'manufacturerId' => "1234567",
        'manufacturerPartNo' => "ABC12345",
        'categoryId' => 10000000,
        'categoryType' => 'default',  
        'skus' => array(
            'sku' => array(
                'type' => 'Internal',
                'number' => "123456ff",
                ),
            ),
        'locales' => array(
                'locale' => array(
                'language' => 'EN',
                'country' => 'US',
                'descriptions' => array(
                    'description' => array("type"=>1,
                                    "_"=>"This is a test")
                                              ),
                'marketingDescription' => array( "_" => "This is the test Marketing Text"),
            ),
        ),
    )
  );
于 2012-06-12T03:40:03.223 回答