Can you debug into Synapse and see why the API context does not get removed
from the path in the first case? That's how it's supposed to work. From the
API class:

           if (restURLPostfix.startsWith(context)) {
                restURLPostfix = restURLPostfix.substring(context.length());
                if (versionStrategy instanceof URLBasedVersionStrategy) {
                    String version = versionStrategy.getVersion();
                    if (restURLPostfix.startsWith(version)) {
                        restURLPostfix =
restURLPostfix.substring(version.length());
                    } else if (restURLPostfix.startsWith("/" + version)) {
                        restURLPostfix =
restURLPostfix.substring(version.length() + 1);
                    }
                }
                ((Axis2MessageContext)
synCtx).getAxis2MessageContext().setProperty(
                        NhttpConstants.REST_URL_POSTFIX, restURLPostfix);
            }

Thanks,
Hiranya

On Wed, Jun 13, 2012 at 2:35 PM, Rajika Kumarasiri <[email protected]> wrote:

> I changed the configuration with following and it completely removed
> everything after the context "/stockquote" and back end complains that the
> operation can't be found because now there is no operation for dispatching
> in the url.
>
> <property name="REST_URL_POSTFIX" action="remove" scope="axis2"/>
>
> The trace from ESB to service:
>
> GET /services/MobileDirectoryService HTTP/1.1
> Content-Type: application/x-www-form-urlencoded; charset=UTF-8
> Accept: */*
> Host: 127.0.0.1:9768
> Connection: Keep-Alive
> User-Agent: Synapse-HttpComponents-NIO
>
>
>
> On Wed, Jun 13, 2012 at 2:06 PM, Hiranya Jayathilaka <[email protected]>wrote:
>
>> Remove the rest url postfix property.
>>
>> On Wed, Jun 13, 2012 at 12:52 PM, Rajika Kumarasiri <[email protected]>wrote:
>>
>>> Same work for following proxy definition for the curl request, curl -X
>>> GET http://localhost:8283/services/StockQuoteProxy/mobile/bbb
>>>
>>> <proxy name="StockQuoteProxy">
>>>         <target>
>>>             <endpoint>
>>>                 <address uri="
>>> http://localhost:9768/services/MobileDirectoryService"; format="rest"/>
>>>             </endpoint>
>>>             <outSequence>
>>>                 <send/>
>>>             </outSequence>
>>>         </target>
>>>     </proxy>
>>>
>>> The trace is now,
>>> client to ESB:
>>> GET /services/StockQuoteProxy/mobile/bbb HTTP/1.1
>>> User-Agent: curl/7.21.7 (x86_64-redhat-linux-gnu) libcurl/7.21.7 NSS/
>>> 3.12.10.0 zlib/1.2.5 libidn/1.22 libssh2/1.2.7
>>> Host: 127.0.0.1:8283
>>> Accept: */*
>>>
>>>
>>> ESB to service:
>>> GET /services/MobileDirectoryService/mobile/bbb HTTP/1.1
>>> Content-Type: application/x-www-form-urlencoded; charset=UTF-8
>>> Accept: */*
>>> Host: 127.0.0.1:9768
>>> Connection: Keep-Alive
>>> User-Agent: Synapse-HttpComponents-NIO
>>>
>>>
>>> Rajika
>>>
>>> On Wed, Jun 13, 2012 at 12:27 PM, Rajika Kumarasiri <[email protected]>wrote:
>>>
>>>> I am trying to use an API to proxy a back end REST service. My
>>>> API deceleration is given below. I have avoided using any url-pattern or
>>>> template in order to define a "pass thru" API.
>>>>
>>>> <api name="StockQuoteAPI" context="/stockquote">
>>>>         <resource methods="POST GET">
>>>>             <inSequence>
>>>>                  <send>
>>>>                     <endpoint>
>>>>                         <address uri="
>>>> http://localhost:9768/services/MobileDirectoryService";
>>>>                                  format="rest"/>
>>>>                     </endpoint>
>>>>                 </send>
>>>>             </inSequence>
>>>>             <outSequence>
>>>>                  <send/>
>>>>             </outSequence>
>>>>         </resource>
>>>>     </api>
>>>>
>>>> I invoked the API using the curl option, curl -X GET
>>>> http://localhost:8283/stockquote/mobile/bbb but ended up with the
>>>> error[1] in the back end. The request message trace is given below.
>>>>
>>>> client to ESB:
>>>> GET /stockquote/mobile/bbb HTTP/1.1
>>>> User-Agent: curl/7.21.7 (x86_64-redhat-linux-gnu) libcurl/7.21.7 NSS/
>>>> 3.12.10.0 zlib/1.2.5 libidn/1.22 libssh2/1.2.7
>>>> Host: 127.0.0.1:8283
>>>> Accept: */*
>>>>
>>>>
>>>> ESB to back end rest service:
>>>> POST /services/MobileDirectoryService/stockquote/mobile/bbb HTTP/1.1
>>>> Content-Type: application/xml; charset=UTF-8
>>>> Accept: */*
>>>> Transfer-Encoding: chunked
>>>> Host: 127.0.0.1:9768
>>>> Connection: Keep-Alive
>>>> User-Agent: Synapse-HttpComponents-NIO
>>>>
>>>>
>>>> It seems problem occurs due to dispatching error of the context
>>>> /stockquote. Any idea to fix the problem ?
>>>>
>>>> Rajika
>>>>
>>>>
>>>>
>>>> [1] -
>>>>
>>>> 2012-06-13 12:17:35,441] ERROR {org.apache.axis2.engine.AxisEngine} -
>>>>  The endpoint reference (EPR) for the Operation not found is
>>>> /services/MobileDirectoryService/stockquote/mobile/bbb and the WSA Action =
>>>> null. If this EPR was previously reachable, please contact the server
>>>> administrator.
>>>> org.apache.axis2.AxisFault: The endpoint reference (EPR) for the
>>>> Operation not found is
>>>> /services/MobileDirectoryService/stockquote/mobile/bbb and the WSA Action =
>>>> null. If this EPR was previously reachable, please contact the server
>>>> administrator.
>>>>  at
>>>> org.apache.axis2.engine.DispatchPhase.checkPostConditions(DispatchPhase.java:102)
>>>> at org.apache.axis2.engine.Phase.invoke(Phase.java:329)
>>>>  at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:262)
>>>> at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:168)
>>>>  at
>>>> org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(RESTUtil.java:144)
>>>> at
>>>> org.apache.axis2.transport.http.util.RESTUtil.processXMLRequest(RESTUtil.java:89)
>>>>  at
>>>> org.apache.axis2.transport.http.AxisServlet$RestRequestProcessor.processXMLRequest(AxisServlet.java:826)
>>>> at
>>>> org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:227)
>>>>  at
>>>> org.wso2.carbon.core.transports.CarbonServlet.doPost(CarbonServlet.java:205)
>>>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
>>>>  at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
>>>> at
>>>> org.eclipse.equinox.http.helper.FilterServletAdaptor$FilterChainImpl.doFilter(FilterServletAdaptor.java:56)
>>>>  at
>>>> org.wso2.carbon.mashup.jsservices.custom.ui.CustomUIServletFilter.doFilter(CustomUIServletFilter.java:233)
>>>> at
>>>> org.eclipse.equinox.http.helper.FilterServletAdaptor.service(FilterServletAdaptor.java:37)
>>>>  at
>>>> org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90)
>>>> at
>>>> org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:111)
>>>>  at
>>>> org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:67)
>>>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
>>>>  at
>>>> org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.service(DelegationServlet.java:45)
>>>> at
>>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
>>>>  at
>>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>>>> at
>>>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
>>>>  at
>>>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
>>>> at
>>>> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
>>>>  at
>>>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
>>>> at
>>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
>>>>  at
>>>> org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:143)
>>>> at
>>>> org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:156)
>>>>  at
>>>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
>>>> at
>>>> org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:48)
>>>>  at
>>>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
>>>> at
>>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
>>>>  at
>>>> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
>>>> at
>>>> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
>>>>  at
>>>> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1620)
>>>> at
>>>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>>>>  at
>>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>>>> at java.lang.Thread.run(Thread.java:619)
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Dev mailing list
>>> [email protected]
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>>
>> --
>> Hiranya Jayathilaka
>> Senior Technical Lead;
>> WSO2 Inc.;  http://wso2.org
>> E-mail: [email protected];  Mobile: +94 77 633 3491
>> Blog: http://techfeast-hiranya.blogspot.com
>>
>
>


-- 
Hiranya Jayathilaka
Senior Technical Lead;
WSO2 Inc.;  http://wso2.org
E-mail: [email protected];  Mobile: +94 77 633 3491
Blog: http://techfeast-hiranya.blogspot.com
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to