【问题标题】:DAS is not sending CORS headerDAS 未发送 CORS 标头
【发布时间】:2016-01-06 01:07:40
【问题描述】:

我正在使用 wso2 的 DAS。我有一个输入适配器类型为 http 的事件接收器。在使用 jquery 的 html 中,我通过 post 方法将 json 发送到此事件。代码很简单:

<script src="jquery.js"></script>
<script>
$( document ).ready(function() {

  $("#senddata").click(function(){
		$.post("http://localhost:9763/endpoints/ex", '{"event": {"payloadData": {"name": "gggg", "age": 37}}}')
			.done(function( data ) {
				console.log( data );
			});
	});
});
</script>

<body>
<input type="button" value="send" id="senddata"></input>
</body>

DAS 在https://localhost:9443 中运行,带有html 和jquery 的应用程序在http://localhost/s 中运行。当我执行应用程序并单击按钮时,控制台显示错误类型“Access-Control-Allow-Origin”。

DAS 文档有一个会话“分析 REST API 的 CORS 设置”(https://docs.wso2.com/display/DAS300/CORS+Settings+for+the+Analytics+REST+API)。我遵循此说明,但没有任何结果。错误仍然存​​在。

这是我的web.xml配置

<filter>
    <filter-name>CorsFilter</filter-name>
    <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
    <init-param>
        <param-name>cors.allowed.origins</param-name>
        <param-value>*</param-value>
    </init-param>
    <init-param>
        <param-name>cors.allowed.methods</param-name>
        <param-value>GET,POST,HEAD,OPTIONS,PUT,DELETE,PATCH</param-value>
    </init-param>
    <init-param>
        <param-name>cors.exposed.headers</param-name>
        <param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>CorsFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

另一方面,当我使用 RESTClient 的 firefox 时,结果是正确的。

【问题讨论】:

  • xml配置正确。发送的数据是持久的。但我没有得到服务器的响应。

标签: wso2 cors wso2-das


【解决方案1】:

您需要使用相同的配置更新内部的 de web.xml:[DAS_HOME]\repository\conf\tomcat\。这不会在以前的 DAS 快照中发生,而是在要更新的配置文件的 3.0.0 版本中发生。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-30
    • 2016-02-16
    • 2020-11-02
    • 2016-04-05
    • 1970-01-01
    • 2018-10-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多