我正在尝试创建一个 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",
),
),
)
);
我在传递非属性值(如实际描述和营销文本)时遇到问题
我将不胜感激任何帮助
很少记录的"_"数组键应该给你部分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"),
),
),
)
);