Hi On Thu, Dec 26, 2013 at 4:20 PM, Aliosha <[email protected]> wrote:
> hi, i need to access the HttpServletRequest as i need to process a rest > http call structured like the following: > > http://localhost:port/myService/[param1,param2,...,paramN]/myIpAddress > Do you have idea how much parameters embedded as given above, if that static,you can define a RESful API [1] and you can define your url-template as uri-template="/myService/{parameter1,parameter2,paramter3}/myIpAddress* Then you should be able to access those variables in via mediation flow as , get-property('uri.var.parameter1') get-property('uri.var.parameter2') But if you don't have any well defined parameter set, above logic will not work refer [2] [1]http://docs.wso2.org/display/ESB480/Getting+Started+with+REST+APIs [2]http://docs.wso2.org/display/ESB480/Configuring+Specific+Use+Cases > i want to avoid in my mediator to process the string " > param1,param2,...,paramN]/myIpAddress" to obtain my parameters. I prefer > to invoke a POST request passing them inside Http payload parameters in the > way i can get them by: > > httpRequest.getParameter("param1") > > I tried to change the transport receiver inside the axis2.xml using the > org.wso2.carbon.core.transports.http.HttpTransportListener > ( I suppose it s not an implementation of the http based on the synapse > http NIO core... so the performance will get lower. isn't? ) > in this way i can get the HttpServletRequest object. But i realized that > this object has Parameters not null only if i append them in the url like a > query string ( i.e. ?param1=param1¶m2=param2....) even if i m sending a > post request. I m using for testing the chrom advanced Rest client and > mozilla poster. > Am i doing anything wrong? > regards > Il 26/dic/2013 08:50 "Dushan Abeyruwan" <[email protected]> ha scritto: > > Hi >> >> >> On Tue, Dec 24, 2013 at 2:57 AM, Aliosha <[email protected]> wrote: >> >>> i have developed a custom mediator and i want to try to publish it as a >>> REST service con my WSO2 ESB 4.7.0. >>> Once i created the REST API, the ESB publishes it on the 8280 port. >>> On the client side, the POST REST call needs to specify some http >>> parameters that i need to recover later in the mediator by this code: >>> >> >> You should refer http://docs.wso2.org/display/ESB480/HTTP+Endpoint where >> you can easily generate request, no need of having custom mediators >> >>> >>> org.apache.axis2.context.MessageContext axis2MsgContext; >>> axis2MsgContext = ((Axis2MessageContext) >>> synapseMsgContext).getAxis2MessageContext(); >>> HttpServletRequest obj = >>> (HttpServletRequest)axis2MsgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST); >>> >>> if (obj != null) { >>> System.out.println("Method :"+ obj.getMethod()); >>> System.out.println("Content-type :" +obj.getContentType()); >>> System.out.println("Content-length :"+obj.getContentLength()); >>> System.out.println("Remote >>> addtress"+obj.getSession().getLastAccessedTime()); >>> } >>> >>> The object i get is always null. >>> That's probably because on 8280 ESB uses the NHttp transport. >>> In what way can i solve this problem? >>> Have i to activate the HTTP Servlet Transport? How can i do this? >>> >> Can I know why you need to use HTTP Servlet for RESTful application >> communication ? Do you have any specific requirement to use it? Why default >> transport shipped with ESB (PTT) not works for you? >> >> >>> What's the difference between HTTP and NHTTP? Does the ESB performance >>> get lower? >>> >> >> >> Obviously, NHTTP far more efficient than Servelet Transport,because >> NHTTP is non blocking invocation and it uses NIO for communication.. by >> default we recommend to use NHTTP because its faster and has high >> performance numbers.. >> >>> Thanks a lot. >>> Best Regards. >>> >> >> >> >> -- >> Dushan Abeyruwan | Associate Tech Lead >> Integration Technologies Team >> PMC Member Apache Synpase >> WSO2 Inc. http://wso2.com/ >> Blog:http://dushansview.blogspot.com/ >> Mobile:(0094)713942042 >> > -- Dushan Abeyruwan | Associate Tech Lead Integration Technologies Team PMC Member Apache Synpase WSO2 Inc. http://wso2.com/ Blog:http://dushansview.blogspot.com/ Mobile:(0094)713942042
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
