T086ѧϰ�� | վ��ѧԺ | �����ĵ� | ���� | Ъ���� | IP��ַ��ѯ | �������� | ���ջ��� | �����ֵ� | ���ù��� | ������Ϣ��ѯ

��phpʵ��soapͨѶ

�� �������ߣ����� ����ʱ�䣺2009-11-23 | ���壺�� �� С��
[����]��PHPʵ��SoapͨѶ ������PHPʵ��SoapͨѶ��д��һЩ�򵥵ķ�������������<?phpfunction HttpSoap($server, $port, $url, $namespace, $action, $data) {$fp = @fsockopen($server, $port);if (!$fp) {return FAL...

��PHPʵ��SoapͨѶ

������PHPʵ��SoapͨѶ��д��һЩ�򵥵ķ�����
��������<?
php
function HttpSoap($server, $port, $url, $namespace, $action, $data) {
$fp = @fsockopen($server, $port);
if (!$fp) {
return FALSE;
} else {
$soapData = ConstructData($namespace, $action, $data);
$length = strlen($soapData);

$out = "POST $url HTTP/1.1 ";
$out .= "Host: $server ";
$out .= "Content-Type: text/xml; charset=utf-8 ";
$out .= "Content-Length: $length ";
$out .= "SOAPAction: ""$namespace$action"" ";
$out .= $soapData;
$out .= " ";

fputs($fp, $out);
stream_set_timeout($fp, 2);

$header = "";
while($line = trim(fgets($fp))) {
$header .= $line." ";
}
$dataPos = strpos($header, "Content-Length: ") + 16;
$dataEnd = strpos($header, " ", $dataPos);
$dataLength = substr($header, $dataPos, $dataEnd - $dataPos);
$data = "";
if($dataLength > 0) {
$data = fread($fp, $dataLength);
}
fclose($fp);
if(strlen($data) != $dataLength || $dataLength <= 0) {
return FALSE;
}
return $data;
}
}

function ConstructData($namespace, $action, $data) {
$soapData = "<?xml version="1.0"" encoding=""utf-8""?>

";
$soapData .= "<soap:Envelope xmlns:xsi=http://www.w3.org/2001/XMLSchema-instancexmlns:xsd=""http://www.w3.org/2001/XMLSchema" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/""> ";
$soapData .= " <soap:Body> ";
$soapData .= " <$action xmlns=""$namespace""> ";
foreach($data as $name => $value) {
$name = iconv("GBK","UTF-8",$name);
$value= iconv("GBK","UTF-8",$value);
$soapData .= " <$name>$value</$name> ";
}
$soapData .= " </$action> ";
$soapData .= " </soap:Body> ";
$soapData .= "</soap:Envelope>";

return $soapData;
}<?
$data=array(
'user'=>'����', //������Ҫ��������������������BASE64����
'pass'=>'test'
);
echo HttpSoap('sample.anyhost.com', 80, '/sampleSoap.asmx', 'http://tempuri.org/', 'logIn', $data);
?>

ע��php5�����Դ���soap��

  • ת����ע����Դ��ITѧϰ�� ��ַ��http://www.t086.com/ �����������Ƽ�������
  • �ر������� ��վ�������ر�������ֹת�ص�ר�������������¿�������ת�أ���������ע��������ԭʼ���ߡ����°�Ȩ������ԭʼ�������С����ڱ���վת�����µĸ��˺���վ�����DZ�ʾ������л�⡣������վת�ص������а�Ȩ��������ϵ���ǣ����ǻᾡ�����Ը�����
  • ��
  • ��
  • ��
  • ��
  • ��
  • ��
  • ��
  • ��
  • ��
������ѯ Health Check Gulangyu
© 2017 T086ѧϰ�� - T086.com(ԭitlearner.com)
RunTime:6.62ms QueryTime:7