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.
Related
I have created a code where an external system can call wso2 esb over TCP and pass data, this is working fine without any issues however the reverse process is not happening and i am getting confused.
Here i would need to pass certain data to external system over TCP, however i am unable to do so as the parameters which are available while developing proxy doesn't contain IP address, it just contain port number, so i am curious as to how can the communication even be established when the IP address is not mentioned in the proxy.
Any help is appreciated.
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="TCPProxyClient"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<inSequence>
<property name="symbol" scope="default" type="STRING" value="IBM"/>
<enrich>
<source clone="true" type="inline">
<m:getQuote xmlns:m="http://services.samples">
<m:request>
<m:symbol>?</m:symbol>
</m:request>
</m:getQuote>
</source>
<target type="body"/>
</enrich>
<enrich>
<source clone="true" property="symbol" type="property"/>
<target xmlns:m="http://services.samples" xpath="//m:getQuote/m:request/m:symbol"/>
</enrich>
<log level="full" separator=","/>
<send/>
</inSequence>
<outSequence>
<log level="full"/>
<send/>
</outSequence>
</target>
<parameter name="transport.tcp.responseClient">true</parameter>
<parameter name="transport.tcp.inputType">string</parameter>
<parameter name="transport.tcp.recordDelimiter">|</parameter>
<parameter name="transport.tcp.contentType">text/xml</parameter>
<parameter name="transport.tcp.port">8691</parameter>
<parameter name="transport.tcp.recordDelimiterType">character</parameter>
<description/>
</proxy>
The parameters above are used only when the proxy is listening for TCP messages. For sending a TCP message to a TCP socket, you need to define an endpoint in the send mediator.
<send>
<endpoint>
<address uri="tcp://localhost:8001/helloService"/>
</endpoint>
<send>
Follow the doc [1] to enable to TCP transport sender in axis2.xml.
Refer the question [2] for more info.
I want to use spring security for authentification but when I try to access the site, I get the 404 error on all requests. I'm trying to debug this for few days, but nothing work for me.
Here is my web.xml :
<!-- Spring MVC -->
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring-database.xml,
/WEB-INF/spring-security.xml
</param-value>
</context-param>
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
spring-security.xml:
<context:component-scan base-package="com.example.users.service"/>
<http auto-config="true" use-expressions="true" authentication-manager-ref="authManager">
<intercept-url pattern="/j_spring_security_check" access="permitAll"/>
<intercept-url pattern="/admin**" access="hasRole('ROLE_ADMIN')" />
<access-denied-handler error-page="/403" />
<form-login
login-page="/login"
default-target-url="/welcome"
authentication-failure-url="/login?error"
username-parameter="username"
password-parameter="password" />
<logout logout-success-url="/login?logout" />
<csrf />
</http>
<authentication-manager id="authManager">
<authentication-provider user-service-ref="myUserDetailsService" />
</authentication-manager>
spring-database.xml:
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/test" />
<property name="username" value="root" />
<property name="password" value="12345678" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="packagesToScan" value="com.example.users.model"/>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
and mvc-dispatcher-servlet.xml:
<context:component-scan base-package="com.example.*" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
Any help would be greatly appreciated.
Thanks.
We don't know what version of Spring Security you are using, but if you have 4.X.X then this url won't work: /j_spring_security_check. They have changed it to /login.
Here is the docs.
I think this config should do the trick:
<http auto-config="true" use-expressions="true" authentication-manager-ref="authManager">
<form-login
login-page="/login"
default-target-url="/welcome"
always-use-default-target="true"
authentication-failure-url="/login?error"
username-parameter="username"
password-parameter="password"/>
<access-denied-handler error-page="/403" />
<intercept-url pattern="/**" access="isAuthenticated()"/>
<intercept-url pattern="/admin/**" access="hasRole('ROLE_ADMIN')"/>
<intercept-url pattern="/login" access="permitAll"/>
<logout logout-success-url="/login?logout" />
<csrf />
</http>
Assuming Dmitriy might have solved this by now, I am answering on the hopes that it may be useful for others who stumble upon on this issue.
I cannot find the spring mvc dispatcher servlet config xml.
We dont need to add component scan specially in the spring security xml configuration if its already taken care in the spring configuration.
The intercept-url pattern="/j_spring_security_check" access="permitAll" may not be required. Spring security is intelligent, it will only apply security for the url pattern mentioned. All other urls are free to access.
Depending on Spring security version, /j_spring_security_check or /login url should be used in the form action. Former is used in Spring 3.x and latter is used in Spring 4.x
login-page attribute in form-login must match a url in the spring mvc application through controller mapping or xml mapping.
Finally, important thing is, if you mess up a single config in spring security xml, spring will let you run the app but it will always result in 404. So make sure you have all urls mapped to controller mapping, all pages are resolvable in the spring mvc application.
For example, if the access-denied-handler error-page="/403" element cannot find /403 mapping then it will result in 404 error though the user is authenticated and authorized successfully.
if you debug the spring security framework how all the filters are working, you can see how your application is behaving.
<i><debug/></i> element in spring security can help.
Please let me know if this helps.
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>
In my spring mvc project the login page is served as a direct url host/context/login.jsp.
My web.xml states dispatcher-servlet url pattern as:
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern> / </url-pattern>
</servlet-mapping>
Also my mvc-dispatcher-servlet.xml is below:
<context:component-scan base-package="com.company" />
<mvc:resources location="/, /assets/"
mapping="/assets/**" />
<mvc:annotation-driven/>
<context:property-placeholder location="classpath*:METAINF/spring/application.properties" />
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<security:http use-expressions="true">
<security:form-login login-page="/login.jsp" login-processing-url="/j_spring_security_check" authentication-failure-url="/login.jsp?login_error=iup"/>
<security:http-basic />
<security:logout />
<security:intercept-url pattern="/admin/**" access="hasRole('ROLE_ADMIN')" />
<security:intercept-url pattern="/WEB-INF/jsp/**" access="hasRole('ROLE_ADMIN')" />
</security:http>
Also I have a jsp file login.jsp just above the WEB-INF folder for direct access.
On my local machine when I do localhost:8080/context/login.jsp everyting runs fine and login.jsp is rendered but on server machine the call is intercepted by DispatcherServlet and it tries to find a corresponding url mapping(which is not present). What could possibly be making it happen. The logs for catalina.out at server machine are as:
-DispatcherServlet with name 'mvc-dispatcher' processing GET request for [/context/login.jsp]
-command not found
-Looking up handler method for path /login.jsp
-command not found
-Did not find handler method for [/login.jsp]
-command not found
-No mapping found for HTTP request with URI [/context/login.jsp] in DispatcherServlet with name 'mvc-dispatcher'
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 :-)