2

我有一个带有 NuSoap 的 Web 服务 WSDL。我将它与 CodeIgniter 一起使用。我遇到了 contexttype-array 返回的问题。这是我的 PHP 代码:

$this->nusoap_server->wsdl->addComplexType(
                    "getJobStatusByIdsResponse",
                    "complexType",
                    "array",
                    "all",
                    "SOAP-ENC:Array",
                    array(),
                    array(
                        'Job' => array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:jobStatusResponse[]', 'minOccurs'=>'1', 'maxOccurs'=>'unbounded')
                    ),
                    'tns:jobStatusResponse'
                );


$this->nusoap_server->wsdl->addComplexType(
                    "getJobStatusByIdsResponse",
                    "complexType",
                    "array",
                    "all",
                    "SOAP-ENC:Array",
                    array(),
                    array(
                        'Job' => array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:jobStatusResponse[]', 'minOccurs'=>'1', 'maxOccurs'=>'unbounded')
                    ),
                    'tns:jobStatusResponse'
                );

$this->nusoap_server->register(
                    "getJobStatusByIds",
                    array('getJobStatusByIdsRequest' => 'tns:getJobStatusByIdsRequest'),
                    array('getJobStatusByIdsResponse' => 'tns:getJobStatusByIdsResponse'),
                    false,
                    false,
                    "rpc",
                    "literal",
                    "get JobStatus By Ids"
);

function getJobStatusByIds($data) {
  return array(array('orderId' => '1000', 'jobStatus' => '5'),array('orderId' => '1001', 'jobStatus' => '3'),array('orderId' => '1002', 'jobStatus' => '7'))
}

我得到这个作为回报:

      <ns1:getJobStatusByIdsResponse xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">
         <getJobStatusByIdsResponse>
            <item>
               <orderId>1001</orderId>
               <jobStatus>5</jobStatus>
            </item>
            <item>
               <orderId>1002</orderId>
               <jobStatus>3</jobStatus>
            </item>
            <item>
               <orderId>1003</orderId>
               <jobStatus>7</jobStatus>
            </item>
         </getJobStatusByIdsResponse>
      </ns1:getJobStatusByIdsResponse>

那不对,不是吗?

我怎样才能得到它(“工作”而不是“项目”):

  <ns1:getJobStatusByIdsResponse xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">
     <getJobStatusByIdsResponse>
        <Job>
           <orderId>1001</orderId>
           <jobStatus>5</jobStatus>
        </Job>
        <Job>
           <orderId>1002</orderId>
           <jobStatus>3</jobStatus>
        </Job>
        <Job>
           <orderId>1003</orderId>
           <jobStatus>7</jobStatus>
        </Job>
     </getJobStatusByIdsResponse>
  </ns1:getJobStatusByIdsResponse>

我可以帮助谁?在哪里可以找到更多关于 NuSoap 的示例?

4

1 回答 1

0

希望这可以帮助。

添加了代码注释以帮助那些无法记住 NuSoap 参数的人。

$this->nusoap_server->register(
                    "getJobStatusByIds",                                                           // method name
                    array('getJobStatusByIdsRequest' => 'tns:getJobStatusByIdsRequest'),           // input params
                    array('getJobStatusByIdsResponse' => 'tns:getJobStatusByIdsResponse'),         // output params
                    false,                                                                         // namespace
                    false,                                                                         // soap action
                    "rpc",                                                                         // style
                    "literal",                                                                     // use
                    "get JobStatus By Ids"                                                         // documentation
);

我认为定义的响应应该是这样的。

// Job Status Result Complex Type (output)
$this->nusoap_server->wsdl->addComplexType(
                        "getJobStatusByIdsResponse",
                        "complexType",
                        "struct",
                        "all",
                        "SOAP-ENC:Array",
                        array('Job' => array('orderId' => 'your value here', jobStatus => 'your value here')),
    );
于 2012-11-26T21:04:46.583 回答