如何在wso2 esb for Filter中了解客户端的URL

时间:2013-04-30 07:30:54

标签: wso2 wso2esb wso2carbon wso2dss

我正在根据URL进行过滤,所以我希望知道我要获取哪个服务请求。我想知道客户端的URL

<proxy xmlns="http://ws.apache.org/ns/synapse" name="Emp" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>         
  <property name="username" expression="//username/text()" scope="default" type="STRING"/>
   <property name="password" expression="//password/text()" scope="default" type="STRING"/>         
         <payloadFactory>            
            <format>               
               <send xmlns="">                  
                  <username>$1</username>                  
                  <password>$2</password>               
               </send>            
            </format>            
            <args>               
               <arg expression="get-property('username')"/>               
               <arg expression="get-property('password')"/>            
            </args>         
         </payloadFactory>         
         <send receive="Emp_Seq">            
            <endpoint> 
<address uri="http://192.168.1.65:8282/services/Login"/>
</endpoint>        
         </send>      
      </inSequence>
      <outSequence/>
   </target>
   <description></description>
</proxy>


URL of above Proxy is http://192.168.1.65:8282/services/Emp

我的第二个代理是基于第一个代理

做一些逻辑
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Login" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <property name="client_ip_address" expression="get-property('axis2','REMOTE_ADDR')" scope="default" type="STRING"/>
         <property name="username" expression="//username/text()" scope="default" type="STRING"/>
         <property name="password" expression="//password/text()" scope="default" type="STRING"/>
        <property name="From" expression="get-property('From')"/>
<property name="Address" expression="get-property('To')"/>
 <filter xmlns:ns="http://org.apache.synapse/xsd" xpath="get-property('From')='/services/Emp'">
      <then>
         <payloadFactory>
            <format>
               <ResponseJSON xmlns="">
                  <Status>404</Status>
                  <Exception>Not Found</Exception>
                  <Total>0</Total>
               </ResponseJSON>
            </format>
         </payloadFactory>
         <send/>
      </then>
      <else>
        <payloadFactory>
            <format>
               <p:login xmlns:p="http://authentication.services.core.carbon.wso2.org">
                  <p:username>$1</p:username>
                  <p:password>$2</p:password>
                  <p:remoteAddress>$3</p:remoteAddress>
               </p:login>
            </format>
            <args>
               <arg expression="//username/text()"/>
               <arg expression="//password/text()"/>
               <arg expression="get-property('client_ip_address')"/>
            </args>
         </payloadFactory>
         <header name="Action" value="urn:login"/>
         <log level="full"/>
         <send receive="Login_Seq">
            <endpoint>
               <address uri="https://192.168.1.65:9443/services/AuthenticationAdmin" format="soap11"/>
            </endpoint>
         </send>
   </filter>


      </inSequence>
      <outSequence>
         <log level="full"/>
              </outSequence>
   </target>
   <description></description>
</proxy>

问题是get-property('To')给出了Address = / services / Login,其中get-property('From')给予senderAddress = null 我怎么能管理这个我有很多属性,即使它不工作
喜欢

<property name="senderAddress" expression="get-property('transport', 'From')"/>
<property name="Sender Address" expression="$url:From"/>
<header name="From" expression="get-property( 'From')"/>
<property name="PRESERVE_WS_ADDRESSING" value="true"/>
            <property xmlns:wsa="http://www.w3.org/2005/08/addressing" name="$header" expression="$header/wsa:From"/>

这个属性也不起作用我们在wso2 esb中没有任何选项如果你知道这个请大致编辑我的代理..简单的depanding逻辑但它在WSO2中不起作用 提前谢谢

1 个答案:

答案 0 :(得分:1)

您应该能够使用REMOTE_HOST或REMOTE_ADDR属性获取客户端的地址。请参阅http://wso2.org/project/esb/java/4.0.3/docs/properties_guide.html#http