使用apache重定向Soap请求

时间:2014-01-19 12:44:51

标签: php apache redirect soap soapui

请原谅我的英语,我是法国人。

我有一个关于使用apache进行soap请求重定向的问题(在wampserver上)。

我在server.php

上有一个文件localhost:3511

vhost:

<VirtualHost *:3511>
DocumentRoot "C:/wamp/www/test/server.php"
ServerName test.local
</VirtualHost>

server.php:

<?php
ini_set('soap.wsdl_cache_enabled', 0);
require_once('Test.php');

$wsdl = "CurrencyConvertor.asmx.wsdl";
$server = new SoapServer($wsdl);
$server->setClass("Test");
$server->handle();
?>

我的班级 Test.php:

<?php
class Test
{
    public function ConversionRate($p_conversion_rate_request)
    {   

        return array('ConversionRateResult' => 0);
    }
}

使用SoapUi,当我调用

时,我有这个结果
http://localhost:3511


<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"     xmlns:ns1="http://www.webserviceX.NET/">
    <SOAP-ENV:Body>
      <ns1:ConversionRateResponse>
         <ns1:ConversionRateResult>0</ns1:ConversionRateResult>
      </ns1:ConversionRateResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

所以它有效!

现在我想将请求重定向到

http://localhost/test2/server.php 

当soapui调用localhost:3511时。 我在localhost/test2/中拥有相同的项目,但ConversionRateResult返回1而不是0

我使用以下代码在localhost/test/中创建了一个htaccess:

Redirect / http://localhost/test2/server.php

当我在网络浏览器中测试此网址localhost:3511时,会调用test2/server.php。它有效,但当我用SoapUi调用localhost:3511时,没有返回任何内容。

你能解释一下我的htaccess有什么问题吗? 可能是我必须添加一些东西吗?

1 个答案:

答案 0 :(得分:1)

使用代理标志[P]:

RewriteEngine on
RewriteRule  /  http://localhost/test2/server.php  [NC, P] 

mod_proxy的: http://httpd.apache.org/docs/current/mod/mod_proxy.htm

标志: http://httpd.apache.org/docs/current/rewrite/proxy.html