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

解决方案 »

  1.   

    不知道soap+xml是什么
    当方法是有的,先全文件夹查找"'text/xml; charset=utf-8'",然后换成'application/soap+xml; charset=utf-8'试试看
      

  2.   

    $parameters=array('text'=>'5do8');
    $username = $client->sayHello($parameters); 
    ============================================================================================
    $parameters一般不这样传,webservice就是跨平台,跨语言的服务,你把一个专属于php的数组类型传到参数中,除非server端也是php写的,否则其它语言根本不识别此类型,w3c对参数类型是有严格规定的。
    感觉就是你这个参数类型错了啊。
      

  3.   


    一共才2个代码文件...这些格式信息应该是服务自动生成的.没找到方法改网上找到的php连接c#写的WCF的例子都是这样传参数的阿