1

我已经检查并尝试了 StackOverflow 上的其他解决方案,但是它对我没有帮助,所以我决定再问一次。

我正在尝试创建一个 SOAP 服务器,打印生成的 WSDL。但是,除了array. 无论我做了什么,我都无法让服务器返回给我一个products. 可能的原因是什么?

这是我的函数代码:

function getProducts() {
    $productList = array();
for($i=0;$i<5;$i++) {
        array_push($productList, array(
            "pName" => "Hello",
            "pBrand" =>"World"
        ));
    }
    return $productList;           
}

这是复杂类型定义和功能寄存器;

$server->wsdl->addComplexType(
    'product',
    'complexType',
    'struct',
    'all',
    '',
    array(
        'pName' => array('name' => 'pName', 'type' => 'xsd:string'),
        'pBrand' => array('name' => 'pBrand', 'type' => 'xsd:string'))
);

$server->wsdl->addComplexType(
    'productList',
    'complexType',
    'array',
    '',
    'SOAP-ENC:Array',
    array(),
    array(
        array('ref' => 'SOAP-ENC:arrayType', 
              'wsdl:arrayType' => 'tns:product[]')
    ),
    'tns:product'
);
$server->register('getProducts',
                      array(),
                      array('productListResult' => 'tns:productList'),
                      'urn:QRWebService',
                      'urn:QRWebService#getProducts',
                      'rpc',
                      'encoded'
                      );
4

0 回答 0