0

我正在使用 PHP(SoapClient 类)创建肥皂请求,但坚持寻找如何创建 Person 对象并将其添加到 InsuredObjects 列表的解决方案。Person 继承 InsuredObject。

原始 WSDL 方案:

<VoyageRequestOfCalculateArgs>
  <MethodName>Calculate</MethodName>
  <Password>0000000000000</Password>
  <RequestData>
    <a:AgentId>9999</a:AgentId>
    <a:SessionKey>999999999999999999</a:SessionKey>
    <a:Contract i:type="b:Voyage">
      <startDate>2013-09-14T23:59:59+02:00</startDate>
      <endDate>2013-09-14T23:59:59+02:00</endDate>
      <b:type>Individual</b:type>
      <b:variant>Standard</b:variant>
      <insuredObjects>
        <InsuredObject i:type="b:Person">
        <b:address i:nil="true"/>
        <b:isOwner>false</b:isOwner>
        <b:ageGroup>AdultBetween4And64</b:ageGroup>
        <b:birthDate>0001-01-01T00:00:00</b:birthDate>
        <b:firstName i:nil="true"/>
        <b:idNumber i:nil="true"/>
        ...
        <errors/>
        <Risks>
         <Risk i:type="c:RiskAssistance">
            <basicRate>0</basicRate>
            ...
            <c:type>LCVASS</c:type>
         </Risk>
      </Risks>
   </InsuredObject>
  </insuredObjects>
</Contract>

...

这是我的请求数组:

$request = array(
                'request' => array(
                    "MethodName" => "Calculate",
                    "RequestData" => array(
                        'AgentId' => $this->config['username'],
                        'SessionKey' => $sessionKey,
                        'Contract' => array(
                            'startDate' => $startDate,
                            'endDate' => $endDate,
                            'type' => 'Individual',
                            'variant' => 'Standard',
                            'country' => array(
                                ...
                            ),
                            'insuredObjects' => array(
                             //-----------------------------------
                             //Here should be added person object.
                             //-----------------------------------
                                array(
                                    'errors' => '',
                                    'risks' => array(
                                        'type' => 'LCVKLS'
                                    ),
                                    'ageGroup' => 'AdultBetween4And64',
                                    'isForeigner' => false,
                                    ...
                                )
                            )
                        )
                    )
                )
            );

$result = $this->client->Calculate($request);

我的request($this->client->__getLastRequest())样子:...

<SOAP-ENV:Body>
    <ns5:Calculate>
        <ns5:request>
            <ns1:MethodName>Calculate</ns1:MethodName>
            <ns1:RequestData>
                <ns2:AgentId>9999</ns2:AgentId>
                <ns2:SessionKey>999999999999999999</ns2:SessionKey>
                <ns2:Contract>
                    <ns3:endDate>2013-09-19</ns3:endDate>
                    <ns3:insuredObjects>
                        <ns3:InsuredObject>
                            <ns3:errors/>
                            <ns3:risks/>
                        </ns3:InsuredObject>
                    </ns3:insuredObjects>
                    <ns3:startDate>2013-09-07</ns3:startDate>
                    <ns4:country>
                        <ns4:Code>EU</ns4:Code>
                        <ns4:Id>132</ns4:Id>
                        <ns4:IsVoyage30Range>true</ns4:IsVoyage30Range>
                        <ns4:Name>Europa</ns4:Name>
                    </ns4:country>
                    <ns4:type>Individual</ns4:type>
                    <ns4:variant>Standard</ns4:variant>
                </ns2:Contract>
            </ns1:RequestData>
        </ns5:request>
    </ns5:Calculate>
</SOAP-ENV:Body>

...

响应错误:

Unable to cast object of type 'Company.Common.BusinessObjects.InsuredObject' to type 'Company.VoyageService.BusinessObjects.Person'.

将属性传递给同样的问题'risks' => 'type' => 'LCVKLS'

我希望你能帮助我找到问题。

4

0 回答 0