WSDL客户端不工作

时间:2013-09-17 13:50:13

标签: php xml web-services soap wsdl

我有一个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对象([message:protected] =&gt; SOAP-ERROR:编码:对象没有&#39; imiPolicy&#39;属性[string:Exception:private] =&gt; [code:protected] =&gt; 0 [file:protected] =&gt; C:\ wamp \ www \ nsoap \ phpclient.php [line:protected] =&gt; 8 [trace:Exception:private] =&gt; Array([0] =&gt; Array( [file] =&gt; C:\ wamp \ www \ nsoap \ phpclient.php [line] =&gt; 8 [function] =&gt; __call [class] =&gt; SoapClient [type] =&gt; - &gt; [args ] =&gt;数组([0] =&gt; getIMIPremium [1] =&gt;数组([0] =&gt;数组([expiryDate] =&gt; 25 [imiInsured] =&gt; N [inceptionDate] =&gt; 43 [noOfInsured] =&gt; 23 [partnerCode] =&gt; 21 [stateCode] =&gt; MP))))[1] =&gt;数组([file] =&gt; C:\ wamp \ www \ nsoap \ phpclient。 php [line] =&gt; 8 [function] =&gt; getIMIPremium [class] =&gt; SoapClient [type] =&gt; - &gt; [args] =&gt;数组([0] =&gt;数组([expiryDate] =&gt; 25 [imiInsured] =&gt; N [inceptionDate] =&gt; 43 [noOfInsured] =&gt; 23 [partnerCode] =&gt; 21 [stateCode] =&gt; MP))))[pre vious:例外:私人] =&gt; [faultstring] =&gt; SOAP-ERROR:编码:对象没有&#39; imiPolicy&#39; property [faultcode] =&gt;客户[faultcodens] =&gt; http://schemas.xmlsoap.org/soap/envelope/ [xdebug_message] =&gt; (!)SoapFault:SOAP-ERROR:编码:对象没有&#39; imiPolicy&#39;第8行C:\ wamp \ www \ nsoap \ phpclient.php中的属性调用堆栈#TimeMemoryFunctionLocation 10.0010672312 {main}().. \ phpclient.php:0 20.0104698552SoapClient-&gt; 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-Modified:Tue,2013年9月17日13:18:39 GMT ETag:&#34; a0000000a818c-12e9-4e69428b54054&#34; Accept-Ranges:bytes Content-Length:4841 Connection:close Content-Type:application / 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] =&gt;错误的版本[string:Exception:private] =&gt; [code:protected] =&gt; 0 [file:protected] =&gt; C:\ wamp \ www \ nsoap \ phpclient.php [line:protected] =&gt; 10 [trace:Exception:private] =&gt; Array([0] =&gt; Array([file] =&gt; C:\ wamp \ www \ nsoap \ phpclient .php [line] =&gt; 10 [function] =&gt; __call [class] =&gt; SoapClient [type] =&gt; - &gt; [args] =&gt;数组([0] =&gt; getIMIPremium [1] =&gt;数组([0] =&gt;数组([imiPolicy] =&gt;数组([expiryDate] =&gt; 23-09-2013 [imiInsured] =&gt;数组([item] =&gt;数组([item] ] =&gt;数组([age] =&gt; 23 [basicSumInsured] =&gt; 33233 [coverRageType] =&gt; 12 [dateOfBirth] =&gt; 26-09-1986 [preExistingDisease] =&gt; no)))[inceptionDate ] =&gt; 12-09-2009 [noOfInsured] =&gt; 1 [partnerCode] =&gt; 2121 [stateCode] =&gt; 233)))))[1] =&gt;数组([file] =&gt; C :\ wamp \ www \ nsoap \ phpclient.php [line] =&gt; 10 [function] =&gt; getIMIPremium [class] =&gt; SoapClient [type] =&gt; - &gt; [ar gs] =&gt;数组([0] =&gt;数组([imiPolicy] =&gt;数组([expiryDate] =&gt; 23-09-2013 [imiInsured] =&gt;数组([item] =&gt;数组([item] =&gt; ;数组([age] =&gt; 23 [basicSumInsured] =&gt; 33233 [coverRageType] =&gt; 12 [dateOfBirth] =&gt; 26-09-1986 [preExistingDisease] =&gt; no)))[inceptionDate] =&gt ; 12-09-2009 [noOfInsured] =&gt; 1 [partnerCode] =&gt; 2121 [stateCode] =&gt; 233)))))[previous:Exception:private] =&gt; [faultstring] =&gt;错误版本[faultcode] =&gt; VersionMismatch [faultcodens] =&gt; http://schemas.xmlsoap.org/soap/envelope/ [xdebug_message] =&gt; (!)SoapFault:第10行C:\ wamp \ www \ nsoap \ phpclient.php中的错误版本调用堆栈#TimeMemoryFunctionLocation 10.0012674576 {main}().. \ phpclient.php:0 20.0184702744SoapClient-&gt; getIMIPremium()。 。\ phpclient.php:10)

1 个答案:

答案 0 :(得分: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:编码:对象在第8行的C:\ wamp \ www \ nsoap \ phpclient.php中没有'imiPolicy'属性调用堆栈#TimeMemoryFunctionLocation 10.0010672312 {main}().. \ phpclient.php

这分解为:

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

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

我认为一旦确定,你就应该好好去。

希望这有帮助。

肯特