从远程服务器连接到localhost

时间:2015-03-02 12:45:14

标签: php soap localhost soap-client

我需要连接到本地端口(8046)以执行本地计算机中安装的服务。如果我启动像Wamp或PHPDesktop这样的本地服务器,我没有问题,但如果我创建了一个Linux服务器(在同一网络上)并且我想调用该服务怎么办?有没有办法做到这一点?

我尝试获取计算机名称并连接到compname:8046,但它无效;有什么建议吗?

$xml='---req--'
$url = 'http://127.0.0.1:8046';

$post_data = array(
    "xml" => $xml,
);

$stream_options = array(
    'http' => array(
       'method'  => 'POST',
       'header'  => "Content-Type: application/xml; charset=UTF-8",
       'content' => urldecode(http_build_query($post_data)),
       'timeout' => 12000,
    ),
);

$context  = stream_context_create($stream_options);
$response = @file_get_contents($url, null, $context);

1 个答案:

答案 0 :(得分:0)

您需要知道要连接的计算机的IP地址,或者如果您在本地网络上运行DNS服务器,则可以使用该名称。然后你就可以像http://000.000.000.000:8046那样访问它,显然用你网络上的实际IP替换0

如果您尝试从远程计算机访问此计算机,请说某处的主机帐户,则需要将路由器配置为将端口8046转发到网络上正确的计算机。

相关问题