header('Content-Type: text/html; charset=utf-8');
$s = new SoapClient('http://域名/WebService.asmx?wsdl');
/*
*SoapHeader参数说明如下所示:
*'http://tempuri.org/' namespace(命名空间可省略)
*'MySoapHeader' SoapHeader头的类名
*'array(...)' 存放标识身份的字符串参数
*'true' 是否必须处理该header
*/
echo 123;
$u = new SoapHeader('http域名/webservice/','MySoapHeader',array('UserName'=>'admin','PassWord'=>'123'),true);
//添加soapheader
$s->__setSoapHeaders($u);
//调取需要的webservice方法
$suc = $s->myprivatestart(array());
echo $suc->myprivatestartResult;
var_dump( get_object_vars($suc));
?>转载请注明出处:
未经允许不得转载:lxfamn » PHP 调用webservice soapheader