我正在尝试使用zend 1.11.7向asp.net soap web服务进行Web服务调用。
文档说明我需要使用以下格式拨打电话:
RequestCustomReport(CustomReportDef,SecurityCredential)
具有以下结构:
<securityCredentials>
<Key>string</Key>
<UserName>string</UserN
<Password>string</Passw
</securityCredentials>
<reportDefinition>
<CustomTemplateId>int</CustomTemplateId>
<StartDate>dateTime</StartDate>
<EndDate>dateTime</EndDate>
<PeriodId>int</PeriodId>
<SiteId>int</SiteId>
<ReportGUID>string</ReportGUID>
<ReportData>base64Binary</ReportData>
<ReportDataType>xml or csv or tsv or txt</ReportDataType>
<CompressReportData>boolean</CompressReportData>
<ReportStatus>Pending or Ready or Error or Deleted</ReportStatus>
<ErrorMessage>string</ErrorMessage>
</reportDefinition>
我的代码是:
$client = new Zend_Soap_Client($ws_url);
$reqFilter = array();
$reqFilter['CustomTemplateId'] = 33117; //33117 = report id
//$reqFilter['StartDate'] =
//$reqFilter[''] ='';
$reqFilter['PeriodId'] = 4; //4 = last 7 days
$reqFilter['SiteId'] =3672;
$reqFilter['ReportDataType'] ='xml';
$reqFilter['CompressReportData'] =0;
$reptXml=new XMLWriter();
$reptXml->openMemory();
$reptXml->startDocument('1.0','UTF-8');
$reptXml->startElement("reportDefinition");
$reptXml->startElement("CustomTemplateId");
$reptXml->text($reqFilter['CustomTemplateId']);
$reptXml->endElement();//CustomTemplateId
$reptXml->startElement("PeriodId");
$reptXml->text($reqFilter['PeriodId']);
$reptXml->endElement();//PeriodId
$reptXml->startElement("SiteId");
$reptXml->text((int)$reqFilter['SiteId']);
$reptXml->endElement();//SiteId
$reptXml->startElement("ReportDataType");
$reptXml->text($reqFilter['ReportDataType']);
$reptXml->endElement();//ReportDataType
$reptXml->startElement("CompressReportData");
$reptXml->text(0);
$reptXml->endElement();// CompressReportData
$reptXml->endElement();//reportDefinition
/*
* securityCredentials xml
*/
$secXml=new XMLWriter();
$secXml->openMemory();
$secXml->startDocument('1.0','UTF-8');
$secXml->startElement("securityCredentials");
$secXml->startElement("Key");
$secXml->text('----');
$secXml->endElement();
$secXml->startElement("UserName");
$secXml->text('--.--');
$secXml->endElement();
$secXml->startElement("Password");
$secXml->text('----');
$secXml->endElement();
$secXml->endElement();
$result = $client->RequestCustomReport($reptXml,$secXml);
但我收到的错误是:
致命错误:未捕获的SoapFault异常:[soap:Sender]报告定义是必需参数,但未在C:\ wamp \ www \ libs \ Zend-1.11.10 \ Zend \ Soap \ Client.php中提供: 1121堆栈跟踪:#0 C:\ wamp \ www \ libs \ Zend-1.11.10 \ Zend \ Soap \ Client.php(1121):SoapClient-&gt; __ soapCall('RequestCustomRe ...',Array,NULL,NULL ,数组)#1 [内部函数]:Zend_Soap_Client-&gt; __ call('RequestCustomRe ...',Array)#2 C:\ wamp \ www \ ProFound_test \ wsdl.php(109):Zend_Soap_Client-&gt; RequestCustomReport(Object (XMLWriter),Object(XMLWriter))#3 {main}在第1121行的C:\ wamp \ www \ libs \ Zend-1.11.10 \ Zend \ Soap \ Client.php中抛出
似乎没有认识到我已将报告定义参数作为正确的节点名称传递。
有人可以帮忙吗?
答案 0 :(得分:6)
我遇到了与SOAP类似的问题。显然Zend_Soap_Client
函数调用不接受变量作为函数参数,但是包含键和参数函数值的数组调用。
所以:
$result = $client->RequestCustomReport($reptXml,$secXml);
实际应该是:
$result = $client->RequestCustomReport(array('xml' => $reptXml, 'key2' => $secXml));
我也不确定您是否需要创建XML文件。也许只是按原样传递$reqFilter
。我相信Zend_Soap_Client
会为您进行转换。
$client->setSoapVersion(SOAP_1_1);
$result = $client->RequestCustomReport(array('startDate' => $startDate, 'endDate' => $endDate));
(注意它是函数调用中的一个数组)
您还可以查看我使用zend_Soap_client编写的示例SOAP使用情况。 https://github.com/aporat/ACH-Direct-Payments-Gateway-PHP