I'm trying to create an API on wso2esb 4.8.1 that is able to use HTTP GET and POST. When a POST request is received the request has to be dispatched to two endpoints. This works fine and I've not added this piece in the example below.
But the HTTP GET request should be handled in a straightforward manner and this does not work. The request is not being forwarded at all and I'm only seeing a time out message in the ESB logs.
I've used wirehark to see if I see an outgoing request on the wire but this is not the case.
To me the HTTP GET looks pretty straight forward, nothing special at all, but it does not get send out by the ESB. Help would be greatly appreciated!
I've added my API description below:
<api xmlns="http://ws.apache.org/ns/synapse" name="myapp" context="/myapp/myservice">
<resource methods="GET">
<inSequence>
<log>
<property name="Message Flow" value="MyApp MyService API - IN"></property>
<property name="HTTP_METHOD IS###########" expression="$axis2:HTTP_METHOD"></property>
</log>
<property name="DISABLE_CHUNKING" value="true" scope="axis2" type="STRING"></property>
<property name="ContentType" value="application/json" scope="axis2" type="STRING"></property>
<property name="HTTP_METHOD" value="GET" scope="axis2"></property>
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"></property>
<send>
<endpoint>
<address uri="http://myserver.com/myapp/myservice/myaction"></address>
</endpoint>
</send>
</inSequence>
<outSequence>
<property name="messageType" value="application/json" scope="axis2"></property>
<property name="ContentType" value="application/json" scope="axis2"></property>
<send></send>
</outSequence>
<faultSequence>
<log level="full">
<property name="MESSAGE" value="Executing default sequence"></property>
<property name="ERROR_CODE" expression="get-property('ERROR_CODE')"></property>
<property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"></property>
</log>
<drop></drop>
</faultSequence>
</resource>
</api>
Related
I'm using WSO2 Developer Studio 3.8.0 to work on ESB configuration and everytime i open a certain API definition file the IDE modify its content. The original file is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/das/assets" name="wso2das-assets-management" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST" protocol="http">
<inSequence>
<clone>
<target>
<sequence>
<log level="custom" separator=",">
<property expression="//*" name="Triggering EventStreamAdminService API call.."/>
</log>
<call>
<endpoint>
<address format="soap12" trace="disable" uri="https://192.168.219.142:9444/services/EventStreamAdminService.EventStreamAdminServiceHttpsSoap12Endpoint/"/>
</endpoint>
</call>
<log description="EventStreamAdminService API call response" level="full">
<property name="WSANSWER" value="true"/>
</log>
</sequence>
</target>
<target>
<sequence>
<log level="custom" separator=",">
<property expression="//*" name="Triggering EventStreamPersistenceAdminService API call.."/>
</log>
<call>
<endpoint>
<address format="soap12" trace="disable" uri="https://192.168.219.142:9444/services/EventStreamPersistenceAdminService.EventStreamPersistenceAdminServiceHttpsSoap12Endpoint/"/>
</endpoint>
</call>
<log
description="EventStreamPersistenceAdminService API call response" level="full">
<property name="WSANSWER" value="true"/>
</log>
</sequence>
</target>
</clone>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
And the file modified by the IDe once opened is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/das/assets" name="wso2das-assets-management" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST" protocol="http">
<inSequence>
<clone>
<target>
<sequence>
<log level="custom" separator=",">
<property expression="//*" name="Triggering EventStreamAdminService API call.."/>
</log>
<call/>
<log description="EventStreamAdminService API call response" level="full">
<property name="WSANSWER" value="true"/>
</log>
</sequence>
</target>
<target>
<sequence>
<log level="custom" separator=",">
<property expression="//*" name="Triggering EventStreamPersistenceAdminService API call.."/>
</log>
<call/>
<log
description="EventStreamPersistenceAdminService API call response" level="full">
<property name="WSANSWER" value="true"/>
</log>
</sequence>
</target>
</clone>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
As you can see the content of the call tag (attribute and child tags) has been removed by the IDE once the file is opened. I suppose this is due to some best practice or restriction impose by the IDE. Any ideas?
This is a bug in devstudio, it is reported # https://wso2.org/jira/browse/TOOLS-3286 and fix will be avaialbe in next release. Will inform you the release date soon.
Our application is protected by siteminder web agent and is on https.
Our application is running on weblogic and is on http.
When the user access protected URL, the siteminder login page(https) is displayed and the user enters his credentials here.
But after successful authentication, the user was redirected to http URL and page cannot be displayed or unable to connect message was displayed.
I fixed this issue by adding redirectHttp10Compatible="false" attribute to my view resolver.
Now, upon logout, the application is redirecting to logout success URL over http rather than https.
redirectHttp10Compatible="false" attribute is still in the same place.
Any help in this regard is very helpful and highly appreciated.
Thanks a lot in advance.
The below are the config files(edited, removed irrelevant lines) :
<-- DISPATCHER SERVLET -->
<context:component-scan base-package="xxx.xxx.controllers"/>
<mvc:annotation-driven />
<mvc:default-servlet-handler/>
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="100000000"/>
</bean>
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:viewClass="org.springframework.web.servlet.view.JstlView"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp"
p:redirectHttp10Compatible="false"
/>
<-- SPRING SECURITY XML FILE -->
<http pattern="/login/login.action" security="none"/>
<http pattern="/login/logout.action" security="none"/>
<http pattern="/WEB-INF/jsp/Login.jsp" security="none"/>
<http pattern="/WEB-INF/jsp/Logout.jsp" security="none"/>
<http auto-config="false" entry-point-ref="http403EntryPoint" use-expressions="true">
<form-login login-page="/login/login.action"
default-target-url="/home.action"
authentication-failure-url="/login/login.action?loginFailed=true"
always-use-default-target="true"/>
<custom-filter ref="siteMinderAgent" position="PRE_AUTH_FILTER"/>
<logout logout-success-url="/login/logout.action"
invalidate-session="true" />
</http>
<beans:bean id="siteMinderAgent"
class="org.springframework.security.web.authentication.preauth.RequestHeaderAuthenticationFilter">
<beans:property name="principalRequestHeader" value="SM_USER"/>
<beans:property name="authenticationManager" ref="appAuthenticationManager" />
</beans:bean>
<beans:bean id="preauthAuthProvider"
class="com.xxx.security.PreAuthenticatedAuthenticationProvider">
<beans:property name="preAuthenticatedUserDetailsService">
<beans:bean id="userDetailsServiceWrapper"
class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper">
<beans:property name="userDetailsService" ref="userDetailsService"/>
</beans:bean>
</beans:property>
</beans:bean>
<beans:bean id="http403EntryPoint"
class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint" />
<authentication-manager alias="appAuthenticationManager">
<authentication-provider ref="preauthAuthProvider"/>
</authentication-manager>
I have set up i18n to my Spring MVC project . The language is not changing when I click on the link:
Hindi
English
controller-servlet.xml
<mvc:annotation-driven/>
<context:component-scan base-package="com.avvas.search.controller" />
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:resources/messages" />
<property name="defaultEncoding" value="UTF-8"/>
<property name="cacheSeconds" value="0" />
</bean>
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="defaultLocale" value="en"/>
</bean>
<bean id="handlerMapping"
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors">
<ref bean="localeChangeInterceptor" />
</property>
</bean>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/pages/" />
<property name="suffix" value=".jsp" />
</bean>
<mvc:resources mapping="/css/**" location="/css/" />
<mvc:resources mapping="/javascript/**" location="/javascript/" />
local changing links:
Hindi
English
The issue is that when i click on hindi the page should be displayed in Hindi language, Language is not getting changed. However i changed default language to hindi <property name="defaultLocale" value="hi"/> then it is taking local as hindi but when i click on english local change link the local is not getting changed.
<mvc:annotation-driven/> is registering its own handler mapping (RequestMappingHandlerMapping) and your interceptor configuration is not applied to that.
Define your interceptor like this:
<mvc:interceptors>
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
</mvc:interceptors>
Here is the Complete code. Basically we need to register our interceptors explicitly.
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
In above given xml you have given "localeChangeInterceptor" but you haven't mentioned anywhere that it should intercept all the requests by default.
So Spring will load all the beans but it wouldn't register it as interceptor until or unless you define that which requests it should intercept.
In below example i am defining it in mvc interceptor and telling the framework that it should consult that interceptor before processing any request.
<mvc:interceptor>
<mvc:mapping path="/**/**/" />
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="locale" />
</bean>
</mvc:interceptor>
</mvc:interceptors>
I use this simple configuration
<beans:bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<beans:property name="basename" value="classpath:localization/messages" />
<beans:property name="defaultEncoding" value="UTF-8" />
</beans:bean>
<interceptors>
<beans:bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<beans:property name="paramName" value="lang" />
</beans:bean>
</interceptors>
<beans:bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<beans:property name="defaultLocale" value="en" />
<beans:property name="cookieMaxAge" value="100000" />
</beans:bean>
Works nice but what if someone will send an url to someone else? This works only with a client browser, If user changes a localization, it will set a cookie. I have seen a lot of websites that they have a localization after the first slash in the url (e.g. nette.org/en/about). When someone send this link, it will resolve localization depending on url. Does exist any simple solution to do this in spring framework? Somehow map this place in url?
Instead of CookieLocaleResolver use SessionLocaleResolver.
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<property name="defaultLocale" value="en"/>
</bean>
I think this should resolve your problem.
Cheers.
Edit: My Spring framework version 3.0.5
A small issue here, The language is not changing when I click the language changer link.
The language files (messages_xx.properties) are in the classpath i18n directory. The files are:
i18n/messages_en.properties
i18n/messages_ar.properties
Spring Configuration
<!-- Component scanner. This is used to automatically find Spring annotations like #Service and #Repository -->
<context:component-scan base-package="com.keype" />
<!-- Annotation driven programming model -->
<mvc:annotation-driven />
<context:annotation-config />
<mvc:resources mapping="/static/**" location="/static/" />
<!-- Session Object Configuration -->
<bean id="session" class="com.keype.system.Session" scope="session">
<aop:scoped-proxy />
</bean>
<!-- The View Resolver -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp"
/>
<!-- i18n Configuration. Default language is english. Change language using ?language=en -->
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<property name="defaultLocale" value="en" />
</bean>
<!-- Message text files. This is set UTF-8 to display Arabic UTF correctly. -->
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:i18n/messages" />
<property name="defaultEncoding" value="UTF-8"/>
</bean>
A section from the JSP Code
<spring:message code="header.arabic" /> |
<spring:message code="header.english" />
The issue is, when I click the above link to change the language, the locale changing functionality is not working. I tested by changing the "defaultLocate" to "ar" and I'm getting Arabic text.
What could possibly be wrong here? There is nothing in the tomcat log also.
You have to register the localeChangeInterceptor among the MVC interceptors for Spring-MVC to consider it. Add the interceptor to the configuration:
<mvc:interceptors>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang"></property>
</bean>
</mvc:interceptors>
<mvc:interceptors>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"
p:paramName="lang" />
</mvc:interceptors>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="defaultLocale" value="en" />
</bean>
Another thing that can help others:
In my case, I MUST add in the applicationContext.xml. Putting it in the spring-servlet (ref. dispatcher), not worked at all.
You need to register the LocaleChangeInterceptor inside the mvc interceptors tag as below,
E.g.
<mvc:interceptors>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="siteLanguage" />
</bean>
</mvc:interceptors>
I was getting the same error and it worked using this code :-)