我收到了来自wsdl webservice的API,我尝试对其进行调用。输入信息时,我只在数组中返回NULL。这就是wsdl的样子:
<xs:element name="Amount">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="securityToken" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="testNo" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="testCode" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
继承我的PHP Soap代码:
<?php
//Create the client object
$soapclient = new SoapClient('https://example.com/Web.svc?singleWsdl');
//Use the functions of the client, the params of the function are in
//the associative array
$testNo = 'ABC123';
$params = array('testNo' => $testNo);
$response = $soapclient->GetPackagePrice($params);
var_dump($response);
?>
答案 0 :(得分:0)
您的SOAP函数不接受任何类。仅发送包含内容的数组
<?php
/* Initialize webservice with your WSDL */
$client = new SoapClient("http://example.com/PublicWeb.svc?singleWsdl");
/* Set your parameters for the request */
$params = array(
"securityToken" => "aString",
"testNo" => "aString",
"testCode" => "aString"
);
/* Invoke webservice method with your parameters, in this case: GetPackageAmount */
$response = $client->GetPackageAmount($params);
/* Print webservice response */
var_dump($response);