【问题标题】:WSDL Client Not WorkingWSDL 客户端不工作
【发布时间】:2013-09-22 00:08:16
【问题描述】:

我有一个 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] => Array ( [file] => C:\wamp\www\nsoap\phpclient.php [line] => 8 [function] => getIMIPremium [class] => SoapClient [type] => -> [args] = > 数组 ( [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] => Clien t [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 on line 8 Call Stack #TimeMemoryFunctionLocation 10.0010672312{main}( )..\phpclient.php:0 20.0104698552SoapClient->getIMIPremium()..\phpclient.php:8)

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

编辑:

我已经创建了一个 php 文件: 客户端.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);
}
}
?>

但它会产生这个错误:

调用错误:响应不是文本/xml 类型:application/wsdl+xmlHTTP/1.1 200 OK 日期:2013 年 9 月 17 日星期二 15:10:38 GMT 服务器:Apache/2.2.22 (Win64) PHP/5.3。 13 上次修改时间: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] = > 数组 ( [expiryDate] => 23-09-2013 [imiInsured] => 数组 ( [item] => 数组 ( [item] => 数组 ( [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] => 数组 ( [0] => 数组 ( [imiPolicy] => 数组 ( [expiryDate] => 23-09-2013 [imiInsured] => 数组 ( [item] =>数组([项目] => 数组([年龄] => 23 [basicSumInsured] => 33233 [coverRageType] => 12 [dateOfBirth] => 26-09-1986 [preExistingDisease] => 否)))[inceptionDate] = > 12-09-2009 [noOfInsured] => 1 [partnerCode] => 2121 [stateCode] => 233 ) ) ) ) ) [previous:Exception:private] => [faultstring] => 错误版本 [faultcode] =>版本不匹配 [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/ [xdebug_message] => ( ! ) SoapFault:第 10 行 C:\wamp\www\nsoap\phpclient.php 中的错误版本调用堆栈#TimeMemoryFunctionLocation 10.0012674576{main}()..\phpclient.php:0 20.0184702744SoapClient->getIMIPremium()..\phpclient .php:10)

【问题讨论】:

  • 您的请求似乎缺少imiPolicy 属性
  • 你能解释一下吗?

标签: php xml web-services soap wsdl


【解决方案1】:

就像之前所说的那样..

错误围绕以下内容:

[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'

我认为一旦设置好了,你就应该做好准备了。

希望这会有所帮助。

肯特

【讨论】:

  • 我也粘贴了我的 php 代码。 $args 有什么严重的问题吗?
  • 不正确的版本我认为我们需要下一步..你应该能够确定:
猜你喜欢
  • 1970-01-01
  • 2015-03-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-20
  • 2021-03-08
  • 2017-03-26
相关资源
最近更新 更多