从SOAP调用中获取数据

问题描述 投票:1回答:1

我收到了来自wsdl网络服务的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);
?>
php soap
1个回答
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);
© www.soinside.com 2019 - 2024. All rights reserved.