文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>php soap方式发送

php soap方式发送

时间:2009-06-17  来源:Digico

$xml.="<data>lu*lu*digico</data>";
//soap 发送

$ret_str = Socket_Connect_HTTP_Post("发送目标IP或域名", "80", "目标文件路径", "目标文件", $xml); //$xml 数据包

 

//返回结果XML解析
$ret_str=str_replace("<?xml version=\"1.0\" encoding=\"GBK\" ?> ","",$ret_str);
$p = xml_parser_create();
xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 1);
xml_parse_into_struct($p,$ret_str,$vals,$index);
xml_parser_free($p);

 

<?

    function Socket_Connect_HTTP_Post($server, $port, $dir, $file, $data)
    {
        if ((substr($dir, -1) != "/") && (substr($file, 0, 1) != "/"))
        {
            $dir .= "/";
        }

        $send_url = str_replace("%2F", "/", rawurlencode(rawurldecode(urldecode($dir . $file))));
        $method = "POST";

        $http_header_array["ALL"][] = "Accept: */*";
        $http_header_array["ALL"][] = "Referer: http://".$server."/";
        $http_header_array["ALL"][] = "Accept-Language: en-us,zh-cn";
        $http_header_array["ALL"][] = "---------------: ----- -------";
        $http_header_array["ALL"][] = "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
        $http_header_array["ALL"][] = "Connection: Keep-Alive";
        $http_header_array["ALL"][] = "Host: ".$server;
        $http_header_array["ALL"][] = "urn:po-processor";

/*
//        $http_header_array["ALL"][] = "Cookie: ";
//        $http_header_array["GET"][] = "If-Modified-Since: Wed, 17 Dec 2003 11:31:54 GMT";
//        $http_header_array["GET"][] = "If-None-Match: 10f047-5b2-3fe03eaa";
*/
        $http_header_array["POST"][] = "Cache-Control: no-cache";
        $http_header_array["POST"][] = "Content-Type: text/xml";  //数据XML格式
        $http_header_array["POST"][] = "Content-Length: ".strlen($data);
       // echo "####################################".$data;

        if (is_array($http_header_array["ALL"]))
        {
            $http_header_str_all = implode("\r\n", $http_header_array["ALL"]);
        }
        if (is_array($http_header_array[$method]))
        {
            $http_header_str_all .= "\r\n".implode("\r\n", $http_header_array[$method]);
        }

        $send_all = "POST ".$send_url." HTTP/1.1\r\n".$http_header_str_all."\r\n\r\n";
        $send_all .= $data."\r\n\r\n";

//        echo "2: ".nl2br($send_all."\n\n\n");


        $fp_send = @fsockopen($server, $port, $errno, $errstr ,30);
//        $times_open++;

        if ($fp_send)
        {
            $can_rcv = 0;
            fputs($fp_send, $send_all);
            stream_set_timeout($fp_send, 120);
            while(!feof($fp_send))
            {
                $content_t = fgets($fp_send, 1024);
                if ((trim($content_t) == "") && !$can_rcv)
                {
                    $can_rcv = 1;
                    $content_t = fgets($fp_send, 1024);
                    //echo $content_t ."@@@@@@@@@@@@@@@\n";

                }
                
                if ($can_rcv == 1 and strlen($content_t)>5)
                {
                    $reply_str .= $content_t;
                }

                //echo "**".$content_t."@@".$can_rcv."&&".$reply_str."\n";


            }
            $stream_status = stream_get_meta_data($fp_send);
            fclose($fp_send);
            if ($stream_status[timed_out])
            {
                $reply_str = "";
            }
        }
        return $reply_str;
    }
?>

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载