我有一个 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>
我想提交信息以获得回复。我创建了客户端.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 没有 'imiPolicy' 属性 [string:Exception:private] => [code: protected] => 0 [file:protected] => C:''wamp''www'soap''phpclient.php [行:protected] => 8 [跟踪:异常:私有] => 数组 ( [0] => 数组 ( [文件] => C:''wamp''www'soap''phpclient.php [行] => 8 [函数] => __call [类] => 肥皂客户端 [类型] => -> [参数] => 数组 ( [0] => getIMIPremium [1] => 数组 ( [0] => 数组 ( [到期日期] => 25 [保险] => N[开始日期] => 43 [无保险] => 23 [合作伙伴代码] => 21 [状态代码] => MP ) ) ) ) [1] => 数组 ( [文件] => C:''wamp''www'soap''phpclient.php [line] => 8 [function] => getIMIPremium [class] => SoapClient [type] => -> [args] => Array ( [0] => Array ( [到期日期] => 25 [imiInsured] => N [inceptionDate] => 43 [noOfInsured] => 23 [partnerCode] => 21 [stateCode] => MP ) ) ) ) [上一页:异常:私有] => [错误字符串] => 肥皂错误: 编码: 对象没有"imiPolicy"属性 [错误代码] =>客户端 [错误代码] => http://schemas.xmlsoap.org/soap/envelope/[xdebug_message] => ( !SoapFault: SOAP-ERROR: Encoding: object 在第 8 行的 C:''wamp''www'soap''phpclient.php 中没有 'imiPolicy' 属性 调用堆栈 #TimeMemoryFunctionLocation 10.0010672312{main}( )..''phpclient.php:020.0104698552SoapClient->getIMIPremium( )..''php客户端.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 日期: 星期二, 17 九月 2013 15:10:38 GMT 服务器: Apache/2.2.22 (Win64) PHP/5.3.13 最后修订日期: 星期二, 17 九月 2013 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'));
但现在错误变成了:
肥皂错误对象 ( [消息:受保护] => 错误版本 [字符串:异常:私有] => [代码:受保护] => 0 [文件:受保护] => C:''wamp''www'soap''phpclient.php [行:受保护] => 10 [跟踪:异常:私有] => 数组 ( [0] => 数组 ( [文件] => C:''wamp''www'soap''phpclient.php [行] => 10 [函数] => __call [类] => 肥皂客户端 [类型] => -> [参数] => 数组 ( [0] => getIMIPremium [1] => 数组 ( [0] => 数组 ( [imiPolicy] => 数组 ([到期日期] => 23-09-2013 [imi保险] => 数组 ( [项目] => 数组 ( [项目] => 数组 ( [年龄] => 23 [基本保险] => 33233 [封面愤怒类型] => 12 [出生日期] => 26-09-1986 [预先存在的疾病] => 否 ) ) ) [开始日期] => 12-09-2009 [无保险] => 1 [合作伙伴代码] => 2121 [州代码] => 233 ) ) ) ) [1] => 数组 ( [文件] => C:''wamp''www'soap''phpclient.php [line] => 10 [function] => getIMIPremium [class] => SoapClient [type] => -> [args] => Array ( [0] => Array ( [imiPolicy] => Array ( [到期日期] => 23-09-2013 [imiInsured] => Array ( [item] => 数组 ( [项目] => 数组 ( [年龄] => 23 [基本保险] => 33233 [封面愤怒类型] => 12 [出生日期] => 26-09-1986 [预先存在的疾病] => 否 ) ) [开始日期] => 12-09-2009 [无保险] => 1 [合作伙伴代码] => 2121 [状态代码] => 233 ) ) ) ) [上一页:异常:私有] => [错误字符串] => 错误版本 [错误代码] => 版本不匹配 [错误代码] => http://schemas.xmlsoap.org/soap/envelope/[xdebug_message] => ( ! )SoapFault: C:''wamp''www'soap''phpclient.php in line 10.0012674576{main}( ).中的错误版本 C:''wamp''www'soap''phpclient 调用堆栈 #TimeMemoryFunctionLocation。''phpclient.php:020.0184702744SoapClient->getIMIPremium( )..''php客户端.php:10 )
就像之前说的一样。
错误围绕以下内容:
[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'soap''phpclient.php 调用堆栈 #TimeMemoryFunctionLocation 10.0010672312{main}( )..''phpclient.php
这分解为:
C:''wamp''www'soap''phpclient.php 在第 8 行调用堆栈 #TimeMemoryFunctionLocation 10.0010672312{main}( )..''phpclient.php
php 文件中是否有一行/设置:"imiPolicy"
我认为一旦设定好,你应该就可以走了。
希望这有帮助。
肯特