发送请求的XML值与我传递的参数不同 - 为什么?

时间:2014-08-05 22:11:51

标签: php xml api soap

我已经工作了好几天试图弄清楚如何从mindbody API接收简单的XML响应。他们的示例代码似乎充满了错误,我一直在慢慢地通过它们。我终于想出了如何在不收到错误的情况下验证和发送XML请求。但是,有一个$startDate$endDate变量未正确填充,我无法弄清楚原因。

以下是发送请求的XML转储部分让我感到困惑:

<ns9:StartClassDateTime>1969-12-31T16:33:33-08:00</ns9:StartClassDateTime>
<ns10:EndClassDateTime>1969-12-31T16:33:03-08:00</ns10:EndClassDateTime>

我正在调用的截断函数是:

public function GetClassDescriptions(array $classDescriptionIDs, array $staffIDs, array $locationIDs, $startDate, $endDate, $PageSize = NULL, $CurrentPage = NULL, $XMLDetail = XMLDetail::Full, $Fields = NULL, SourceCredentials $credentials = null)
    {
        ...
        if (isset($startDate))
        {
            $additions['StartClassDateTime'] = $startDate;
        }
        if (isset($endDate))
        {
            $additions['EndClassDateTime'] = $endDate;
        }

        ...
    }

我的电话是:

 $result = $classService->GetClassDescriptions(array(), array(), array(), 2014-08-01, 2014-08-31, 9, 0);

我完全不确定为什么XML请求会显示与我传递的格式不同的格式?

冒着长途跋涉的风险,我会包含完整的功能,因为我看不到数据的更改位置:

public function GetClassDescriptions(array $classDescriptionIDs, array $staffIDs, array $locationIDs, $startDate, $endDate, $PageSize = NULL, $CurrentPage = NULL, $XMLDetail = XMLDetail::Full, $Fields = NULL, SourceCredentials $credentials = null)
    {
        $additions = array(); 
        if (count($classDescriptionIDs) > 0)
        {
            $additions['ClassDescriptionsIDs'] = $classDescriptionIDs;
        }
        if (count($staffIDs) > 0)
        {
            $additions['StaffIDs'] = $staffIDs;
        }
        if (count($locationIDs) > 0)
        {
            $additions['LocationIDs'] = $locationIDs;
        }
        if (isset($startDate))
        {
            $additions['StartClassDateTime'] = $startDate;
        }
        if (isset($endDate))
        {
            $additions['EndClassDateTime'] = $endDate;
        }


        $params = $this->GetMindbodyParams($additions, $this->GetCredentials($credentials), $XMLDetail, $PageSize, $CurrentPage, $Fields);

            try
        {
            $result = $this->client->GetClassDescriptions($params);

        }

        catch (SoapFault $fault)
        {
            DebugResponse($this->client,$result);
            echo '</xmp><br/><br/> Error Message : <br/>', $fault->getMessage(); 
        }

        if ($this->debug)
        {
            DebugRequest($this->client);
            DebugResponse($this->client, $result);
        }

        return $result;
    }

还有GetMindbodyParams函数:

protected function GetMindbodyParams($additions, $credentials, $XMLDetail, $PageSize, $CurrentPage, $Fields, $UserCredentials = null)
    {
        $params['SourceCredentials'] = $credentials->ConvertToSOAP();
        $params['XMLDetail'] = $XMLDetail;
        $params['PageSize'] = $PageSize;
        $params['CurrentPageIndex'] = $CurrentPage;
        $params['Fields'] = $Fields;
        if (isset($UserCredentials))
        {
            $params['UserCredentials'] = $UserCredentials->ConvertToSOAP();
        }

        // Add the additions array and wrap it in Request
        return array('Request' => array_merge($params, $additions));
    }

0 个答案:

没有答案