在.net2008里做了一个WCF服务,实现单据的传递功能。在.net里做客户以及用微软的WCFClientTest测试都没有问题,但是Php里调用有问题,第一次用Php,不知道是Php的问题还是WCF服务有问题。代码如下:
<?php
header ( "Content-Type:text/xml; charset=gb2312" );
/*
* 指定WebService路径并初始化一个WebService客户端
*/
error_reporting(E_ALL & ~E_NOTICE);
$ws = "http://localhost:49679/TranVouchService.svc?wsdl";//webservice服务的地址
$client = new SoapClient ($ws);
/*
* 获取SoapClient对象引用的服务所提供的所有方法
*/
echo ("SOAP服务器提供的开放函数:");
echo ('<pre>');
var_dump ( $client->__getFunctions () );//获取服务器上提供的方法
echo ('</pre>');
echo ("SOAP服务器提供的Type:");
echo ('<pre>');
var_dump ( $client->__getTypes () );//获取服务器上数据类型
echo ('</pre>');
echo ("执行GetGUIDNode的结果:");
$args = array('cVouchType' => 'DispatchList','iLine'=>2);
$Client->getVouchXmlStyle($args); // 这一行报错了 Call to a member function on null
echo $result->getVouchXmlStyleResult;//显示结果
var_dump($result)
?>
显示的错误:
SOAP服务器提供的开放函数:<pre>array(2) {
[0] =>
string(71) "getVouchXmlStyleResponse getVouchXmlStyle(getVouchXmlStyle $parameters)"
[1] =>
string(107) "OperationDispatchListVoucherResponse OperationDispatchListVoucher(OperationDispatchListVoucher $parameters)"
}
</pre>SOAP服务器提供的Type:<pre>array(9) {
[0] =>
string(108) "struct CompositeType {
string ErrString;
boolean bSuccess;
string domBodyString;
string domHeadString;
}"
[1] =>
string(74) "struct ReturnType {
string ErrString;
boolean bSuccess;
string cCode;
}"
[2] =>
string(57) "struct getVouchXmlStyle {
string cVoucher;
int iLine;
}"
[3] =>
string(74) "struct getVouchXmlStyleResponse {
CompositeType getVouchXmlStyleResult;
}"
[4] =>
string(73) "struct OperationDispatchListVoucher {
string domHead;
string domBody;
}"
[5] =>
string(95) "struct OperationDispatchListVoucherResponse {
ReturnType OperationDispatchListVoucherResult;
}"
[6] =>
string(8) "int char"
[7] =>
string(17) "duration duration"
[8] =>
string(11) "string guid"
}
</pre>执行GetGUIDNode的结果:
Fatal error: Call to a member function getVouchXmlStyle() on null in D:\PhpTest\PhpTest\Test.php on line 22
Call Stack:
0.2030 123328 1. {main}() D:\PhpTest\PhpTest\Test.php:0
PHP Fatal error: Call to a member function getVouchXmlStyle() on null in D:\PhpTest\PhpTest\Test.php on line 22
PHP Stack trace:
PHP 1. {main}() D:\PhpTest\PhpTest\Test.php:0
请高手们提供支援,谢谢啦