昨天遇到一让LZ很郁闷的事,在一个企业站上集成C#提供的接口。这接口的提供者提供了一个JS调用的方法,但是在本地可以运行,传到IIS的服务器上就不行了。度娘一下发现是JS的跨域问题。既然不会配置IIS,那么我就直接用PHP的SOAP。
要使用这个东东。必须把“php_soap.dll”这个扩展打开(WINDOWS下)。打开之后,重启WEB服务器
以下是我的代码。
header('Content-Type: text/html; charset=utf-8');
//新建SOAP客户端
$client = new SoapClient(http://x.x.x.x:90/Service.asmx?WSDL);
//调用接口方法,参数用数组形式传递如果不确定
//可用$client->__getFunctions();
$result = $client->GetRptInfo(array(
'orderid' => 'J2012001' ,
'rptid' => '' ,
'ordersdate' => '' ,
'orderedate' => '' ,
'wunit' => '' ,
'wname' => '' ,
));
$std_class =get_object_vars($result);
$final_std_class = get_object_vars($std_class['GetRptInfoResult']);
$xml_temp_str = $final_std_class['any'];
$xml_result_str = substr($xml_temp_str , strpos($xml_temp_str , '</xs:schema>')+12);
$xml_target = simplexml_load_string($xml_result_str);
echo $xml_target->DocumentElement->GetRptFlow->taskstate;