我正在努力在 Zend Soap Client 实例中创建正确的 SOAP 信封。
以下是从 WSDL 文件生成的预期信封示例:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v1="http://coc.gov/xsd/ESB/SupplementalData/V1"
xmlns:ns="http://schemas.calgary.ca/xsd/familycommunitysurvey/2012/08"
xmlns:ns1="http://schemas.calgary.ca/xsd/familycommunitysurveycdm/2012/08">
<soapenv:Header>
<v1:SupplementalData>
<v1:SourceName>CFS</v1:SourceName>
<v1:ServiceProvider>
<v1:Name>FamilyCommunitySurvey</v1:Name>
<v1:OperationName>GetCodeLookupByName</v1:OperationName>
</v1:ServiceProvider>
<v1:CorrelationID>23451235634</v1:CorrelationID>
</v1:SupplementalData>
</soapenv:Header>
<soapenv:Body>
<ns:GetCodeLookupByNameRequest>
<ns1:Name>Country</ns1:Name>
</ns:GetCodeLookupByNameRequest>
</soapenv:Body>
</soapenv:Envelope>
我需要设置的属性是标题中的“SourceName”、“CorrelationID”和正文中的“Name”。这是我的做法:
$fsiiConnect = new Zend_Soap_Client($wsdl, array('soap_version' => SOAP_1_1));
$fsiiConnect->setLocation($endPoint);
$fsiiConnect->setHttpLogin($userName);
$fsiiConnect->setHttpPassword($password);
$data=array(
'SourceName' => 'CFS',
'CorrelationID' => '1234251435632',
'Name' => 'Country'
);
try {
$results = $fsiiConnect->GetCodeLookupsByName($data);
}
catch (Exception $e) {
print $fsiiConnect->getLastRequest();
}
getLastRequest() 的内容是:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://schemas.calgary.ca/xsd/familycommunitysurveycdm/2012/08"
xmlns:ns2="http://schemas.calgary.ca/xsd/familycommunitysurvey/2012/08">
<SOAP-ENV:Body>
<ns2:GetCodeLookupByNameRequest>
<ns1:Name>Country</ns1:Name>
</ns2:GetCodeLookupByNameRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
所以它只为正文中的对象设置属性,而不是标题。任何想法为什么将不胜感激!