0

我有一个 wsdl :

<?xml version="1.0" encoding="UTF-8"?>

  <wsdl:part element="impl:getIMIPremiumResponse" name="parameters">

  </wsdl:part>

  <wsdl:part element="impl:getIMIPremium" name="parameters">

  </wsdl:part>

  <wsdl:operation name="getIMIPremium">

     <wsdl:input message="impl:getIMIPremiumRequest" name="getIMIPremiumRequest">

   </wsdl:input>

     <wsdl:output message="impl:getIMIPremiumResponse" name="getIMIPremiumResponse">

   </wsdl:output>

  </wsdl:operation>

  <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

  <wsdl:operation name="getIMIPremium">

     <wsdlsoap:operation soapAction=""/>

     <wsdl:input name="getIMIPremiumRequest">

        <wsdlsoap:body use="literal"/>

     </wsdl:input>

     <wsdl:output name="getIMIPremiumResponse">

        <wsdlsoap:body use="literal"/>

     </wsdl:output>

  </wsdl:operation>

  <wsdl:port binding="impl:IMIPremiumWebServiceSoapBinding" name="IMIPremiumWebService">

     <wsdlsoap:address location="http://mysite.com/nsoap/IMIPremiumWebService.wsdl"/>

  </wsdl:port>

我想提交信息以获得回复。我创建了 client.php,如下所示:

    <?php

try{
$client = new SoapClient("http://mysite.com/nsoap/IMIPremiumWebService.wsdl");


$args= array("expiryDate"=>'25',"imiInsured"=>'N',"inceptionDate"=>'43',"noOfInsured"=>'23',"partnerCode"=>'21',"stateCode"=>'MP' );
$something =  $client->getIMIPremium($args);
echo $client->responseData;

}
catch (Exception $e)
{
    print_r($e);
}

?>

但它在浏览器中显示错误:

SoapFault Object ( [message:protected] => SOAP-ERROR: Encoding: object has no 'imiPolicy' property [string:Exception:private] => [code:protected] => 0 [file:protected] => C:\ wamp\www\nsoap\phpclient.php [line:protected] => 8 [trace:Exception:private] => Array ([0] => Array ([file] => C:\wamp\www\nsoap\phpclient .php [line] => 8 [function] => __call [class] => SoapClient [type] => -> [args] => Array ( [0] => getIMIPremium [1] => Array ( [0] => 数组 ( [expiryDate] => 25 [imiInsured] => N [inceptionDate] => 43 [noOfInsured] => 23 [partnerCode] => 21 [stateCode] => MP ) ) ) ) [1] => 数组( [file] => C:\wamp\www\nsoap\phpclient.php [line] => 8 [function] => getIMIPremium [class] => SoapClient [type] => -> [args] => Array ( [0] =>数组 ( [expiryDate] => 25 [imiInsured] => N [inceptionDate] => 43 [noOfInsured] => 23 [partnerCode] => 21 [stateCode] => MP ) ) ) [previous:Exception:private] = > [faultstring] => SOAP-ERROR: Encoding: object has no 'imiPolicy' property [faultcode] => Client [faultcodens] =>http://schemas.xmlsoap.org/soap/envelope/ [xdebug_message] => (!) SoapFault: SOAP-ERROR: Encoding: object has no 'imiPolicy' property in C:\wamp\www\nsoap\phpclient.php在第 8 行调用堆栈#TimeMemoryFunctionLocation 10.0010672312{main}()..\phpclient.php:0 20.0104698552SoapClient->getIMIPremium()..\phpclient.php:8)

我哪里错了?对此应该有什么可能的解决方案?

编辑 :

我创建了一个 php 文件:client.php

    <?php
require_once('nusoap.php');

$client = new nusoap_client('http://localhost/nsoap/IMIPremiumWebService.wsdl', True);


$err = $client->getError();
if ($err) {
// Display the error
echo 'client construction error: ' . $err ;
} else {
$args= array("imiPolicy" => array("expiryDate" => "23-09-2013", "imiInsured" =>array("item" => array("item" => array("age"=>'23', "basicSumInsured"=>'33233', "coverRageType"=>'12',"dateOfBirth"=>'26-09-1986',"preExistingDisease" => 'no'))), "inceptionDate"=>"12-09-2009" ,"noOfInsured"=>'1',"partnerCode" => '2121', "stateCode" => '233'));

$answer = $client->call('getIMIPremium',
$args);

$err = $client->getError();
if ($err) {
// Display the error
echo 'Call error: ' . $err;
 echo $client->response;
//print_r($client->response);
//print_r($client->getDebug());
} else {
    echo "*******************";
print_r($answer);
}
}
?>

但它正在产生这个错误:

调用错误:响应不是 text/xml 类型:application/wsdl+xmlHTTP/1.1 200 OK 日期:2013 年 9 月 17 日星期二 15:10:38 GMT 服务器:Apache/2.2.22 (Win64) PHP/5.3.13 Last-已修改:2013 年 9 月 17 日星期二 13:18:39 GMT ETag:“a0000000a818c-12e9-4e69428b54054”接受范围:字节内容长度:4841 连接:关闭内容类型:应用程序/wsdl+xml

根据建议,我在 $args 添加了 imiPolicy :

$args= array("imiPolicy" => array("expiryDate" => "23-09-2013", "imiInsured" =>array("item" => array("item" => array("age"=>'23', "basicSumInsured"=>'33233', "coverRageType"=>'12',"dateOfBirth"=>'26-09-1986',"preExistingDisease" => 'no'))), "inceptionDate"=>"12-09-2009" ,"noOfInsured"=>'1',"partnerCode" => '2121', "stateCode" => '233'));

但现在错误变为:

SoapFault 对象 ( [message:protected] => 错误版本 [string:Exception:private] => [code:protected] => 0 [file:protected] => C:\wamp\www\nsoap\phpclient.php [line :protected] => 10 [trace:Exception:private] => Array ([0] => Array ([file] => C:\wamp\www\nsoap\phpclient.php [line] => 10 [function] => __call [class] => SoapClient [type] => -> [args] => Array ( [0] => getIMIPremium [1] => Array ( [0] => Array ( [imiPolicy] => Array ( [expiryDate] => 23-09-2013 [imiInsured] => Array ( [item] => Array ( [item] => Array ( [age] => 23 [basicSumInsured] => 33233 [coverRageType] => 12 [ dateOfBirth] => 26-09-1986 [preExistingDisease] => no ) ) ) [inceptionDate] => 12-09-2009 [noOfInsured] => 1 [partnerCode] => 2121 [stateCode] => 233 ) ) ) ) ) [1] =>Array ( [file] => C:\wamp\www\nsoap\phpclient.php [line] => 10 [function] => getIMIPremium [class] => SoapClient [type] => -> [args] => Array ( [0] => Array ( [imiPolicy] => Array ( [expiryDate] => 23-09-2013 [imiInsured] => Array ( [item] => Array ( [item] => Array ( [age] = > 23 [basicSumInsured] => 33233 [coverRageType] => 12 [dateOfBirth] => 26-09-1986 [preExistingDisease] => no ) ) [inceptionDate] => 12-09-2009 [noOfInsured] => 1 [ partnerCode] => 2121 [stateCode] => 233 ) ) ) ) ) [previous:Exception:private] => [faultstring] => 错误版本 [faultcode] => VersionMismatch [faultcodens] =>Array ( [imiPolicy] => Array ( [expiryDate] => 23-09-2013 [imiInsured] => Array ( [item] => Array ( [item] => Array ( [age] => 23 [basicSumInsured] = > 33233 [coverRageType] => 12 [dateOfBirth] => 26-09-1986 [preExistingDisease] => no ) ) [inceptionDate] => 12-09-2009 [noOfInsured] => 1 [partnerCode] => 2121 [ stateCode] => 233 ) ) ) ) [previous:Exception:private] => [faultstring] => 错误版本 [faultcode] => VersionMismatch [faultcodens] =>Array ( [imiPolicy] => Array ( [expiryDate] => 23-09-2013 [imiInsured] => Array ( [item] => Array ( [item] => Array ( [age] => 23 [basicSumInsured] = > 33233 [coverRageType] => 12 [dateOfBirth] => 26-09-1986 [preExistingDisease] => no ) ) [inceptionDate] => 12-09-2009 [noOfInsured] => 1 [partnerCode] => 2121 [ stateCode] => 233 ) ) ) ) [previous:Exception:private] => [faultstring] => 错误版本 [faultcode] => VersionMismatch [faultcodens] =>233 ) ) ) ) ) [previous:Exception:private] => [faultstring] => 错误版本 [faultcode] => VersionMismatch [faultcodens] =>233 ) ) ) ) ) [previous:Exception:private] => [faultstring] => 错误版本 [faultcode] => VersionMismatch [faultcodens] =>http://schemas.xmlsoap.org/soap/envelope/ [xdebug_message] => (!) SoapFault: Wrong Version in C:\wamp\www\nsoap\phpclient.php on line 10 Call Stack #TimeMemoryFunctionLocation 10.0012674576{main} ()..\phpclient.php:0 20.0184702744SoapClient->getIMIPremium()..\phpclient.php:10)

4

1 回答 1

0

和之前说的一样。。

错误围绕以下内容:

[xdebug_message] => ( ! ) SoapFault: SOAP-ERROR: Encoding: object has no 'imiPolicy' property in C:\wamp\www\nsoap\phpclient.php on line 8 Call Stack #TimeMemoryFunctionLocation 10.0010672312{main}( )..\phpclient.php:0 20.0104698552SoapClient->getIMIPremium( )..\phpclient.php:8 ) 

让我们把它分开:

OAP-ERROR: Encoding: object has no 'imiPolicy' property in C:\wamp\www\nsoap\phpclient.php on line 8 Call Stack #TimeMemoryFunctionLocation 10.0010672312{main}( )..\phpclient.php

这分解为:

C:\wamp\www\nsoap\phpclient.php 第 8 行调用堆栈#TimeMemoryFunctionLocation 10.0010672312{main}( )..\phpclient.php

php文件中是否有一行/设置:'imiPolicy'

我认为一旦设置好了,你应该可以开始了。

希望这可以帮助。

肯特

于 2013-09-17T17:07:40.133 回答