title: wso2 esb customURI / serviceURI with expression
body: <p>I am trying to implement ESB solution to replace a web-tier part of a complex web-service architecture. The web-tier just receives the request from clients and distributes to a given set of app-tier instances.</p>
  
  <p>Since the end-points are already defined and used by clients, I had to build the ESB proxy using the "CustomURI" approach as described here - <a href="http://achala11.blogspot.com/2012/08/access-wsdl-for-customuri-wso2-esb.html" rel="nofollow">http://achala11.blogspot.com/2012/08/access-wsdl-for-customuri-wso2-esb.html</a> - to expose the end-point and wsdl.</p>
  
  <p>Note that ServiceURI only allows to specify a fixed context path (correct me if I am wrong). For example:
  If WSDL end-point is http:// localhost:8280/CustomURL/Part1/Part2?wsdl, the corresponding ServiceURI entry is</p>
  
  <pre><code>&lt;parameter name="ServiceURI"&gt;/CustomURL/Part1/Part2&lt;/parameter&gt; 
  </code></pre>
  
  <p>What I want to use is an expression like this:</p>
  
  <pre><code>&lt;parameter name="ServiceURI"&gt;/CustomURL/*&lt;/parameter&gt;
  </code></pre>
  
  <p>to indicate that all requests that starts with /CustomURL in the context path will be handled by the proxy. Inside the proxy, I like to propagate the context URI to the endpoint defined in the send block. I think I found a RESTful way (didn't get it to work completely) of doing what I am trying to do here. As you can see, I can specify a context in the api and then use url-mapping option of resource to route all request to the api block. Later I am trying to use the "http endpoint" approach to construct the endpoint with the contextURI appended.</p>
  
  <pre><code>&lt;api xmlns="http://ws.apache.org/ns/synapse" name="customService1" context="/CustomServices"&gt;
  &lt;resource methods="POST" url-mapping="/*"&gt;
    &lt;inSequence&gt;
       &lt;log level="custom"&gt;
          &lt;property name="uri.var.servicepath" expression="get-property('To')"/&gt;
       &lt;/log&gt;
       &lt;send&gt;
          &lt;endpoint name="HTTPEndpoint"&gt;
             &lt;http method="POST" uri-template="http://localhost:8001/{uri.var.servicepath}"/&gt;
          &lt;/endpoint&gt;
       &lt;/send&gt;
    &lt;/inSequence&gt;
    &lt;outSequence&gt;
       &lt;send/&gt;
    &lt;/outSequence&gt;
  &lt;/resource&gt;
  &lt;/api&gt;
  </code></pre>
  
  <p>I hope you can help me with a similar solution for SOAP services - a way to specify a contextURI and then include the contextURI to the final endpoint that the proxy will send the request to. Note that the endpoints will be a list of entries (load balanced entries), but to keep things simple, I just kept one endpoint entry above.</p>