PHP soap客户端请求元素

时间:2012-06-12 01:46:21

标签: php web-services soap

我正在尝试创建一个部分包含以下内容的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",
        ),
      ),
    )
  );

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

我将不胜感激任何帮助

1 个答案:

答案 0 :(得分:0)

少量记录的“_”数组键应该为您提供部分XML的值(在评论here中找到并在SO here上提及)。在你的例子中,沿着这些方向的东西 - 当然未经测试:

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"),
            ),
        ),
    )
  );