php连接wcf时报错
wcf程序是基本的模板程序,
能够正常连接名输出wcf服务的信息,但是调用方法的时候就出错
php代码
<?php
echo "WCF Test\r\n\r\n";
$ws = "http://localhost:8080/service1?wsdl";
$client = new SoapClient($ws,array(
'soap_version' => SOAP_1_1,
'trace' => 1,
'exceptions' => 1
));
echo('<pre>');
var_dump($client->__getFunctions());
echo('</pre>');
echo("SOAP服务器提供的Type:");
echo('<pre>');
var_dump($client->__getTypes());
echo('</pre>');
echo("执行sayHello的结果: <br />");
try {
$parameters=array('text'=>'5do8');
$username = $client->sayHello($parameters);
} catch (SoapFault $fault){
echo "Fault! code:",$fault->faultcode,", string: ",$fault->faultstring;
}
//echo(htmlspecialchars($client->__getLastRequest()));
echo('<pre>');
if(is_array($username))
{
foreach($username as $key => $val) {
echo($val);
}
}
echo('</pre>');
?>
页面输出
WCF Test
array(1) {
[0]=>
string(47) "sayHelloResponse sayHello(sayHello $parameters)"
}
SOAP服务器提供的Type:
array(5) {
[0]=>
string(33) "struct sayHello {
string text;
}"
[1]=>
string(51) "struct sayHelloResponse {
string sayHelloResult;
}"
[2]=>
string(8) "int char"
[3]=>
string(17) "duration duration"
[4]=>
string(11) "string guid"
}
执行sayHello的结果:
Fault! code:HTTP, string: Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'.