这是我的极速代码在soap API上请求的功能。我一直收到错误“对象引用未设置为对象的实例”。但响应为200。我需要生成QuotationNo。
我需要将这些数据发布到外部API数据库
数据成功发布到数据库后,将创建报价单
public function getQuotation()
{
$factory = new Factory();
$client = $factory->create(new Client(), 'http://something.com/GetQuotation/GetQuotation.asmx?WSDL',
[
'stream' => true,
'stream_context' => [
'ssl' => [
'allow_self_signed' => true
],
'socket' => [
'bindto' => 'serveripaddress'
]
]
]
);
$data = [
'param' => [
'TokenId' => '1pBt8l93-aTX1-E7J6-A6Qx-cWb3Abc84Eg6',
'AgentCode' => '30144-36-C',
'AgentID' => 'hqrebate',
'SumInsured' => 98005,
'BasicPrem' => 23006,
'ClassCode' => '2-01',
'SubClassCode' => '01',
'CarRegistrationNo' => 'PGS3881',
'InsuredName' => 'Testing Insured',
'InsuredIC' => '830711075133',
'InsuredEmail' => 'testing@hotmail.com',
'InsuredContactNo' => '60123450005',
'InsuredAddress1' => '153,',
'InsuredAddress2' => 'Jln Persiaran Meranti,',
'InsuredAddress3' => 'Bandar Seri Damansara',
'InsuredPostcode' => '55220'
]
];
$result = $client->call('GenerateQuotation', $data);
var_dump($result);
exit;
}
这是wsdl格式
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<s:element name="GenerateQuotation">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="param" type="tns:QuotationReq"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="QuotationReq">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="TokenId" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="AgentCode" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="AgentID" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="SumInsured" type="s:double"/>
<s:element minOccurs="1" maxOccurs="1" name="BasicPrem" type="s:double"/>
<s:element minOccurs="0" maxOccurs="1" name="ClassCode" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="SubClassCode" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="CarRegistrationNo" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="InsuredName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="InsuredIC" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="InsuredEmail" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="InsuredContactNo" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="InsuredAddress1" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="InsuredAddress2" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="InsuredAddress3" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="InsuredPostcode" type="s:string"/>
</s:sequence>
</s:complexType>
<s:element name="GenerateQuotationResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GenerateQuotationResult" type="tns:QuotationResp"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="QuotationResp">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="QuotationNo" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="ErrorDesc" type="s:string"/>
</s:sequence>
</s:complexType>
</s:schema>
</wsdl:types>
对于那些可以帮助我的人,我非常感谢,因为我已经有一段时间遇到了这个问题。
答案 0 :(得分:0)
我只是修改了这个: $ result = $ client-> call('GenerateQuotation',$ data);
对此: $ result = $ client-> call('GenerateQuotation',[$ data]);
工作完成。