【问题标题】:wso2 API Manager, java Restfull Endpoint can't be found when calling the API through the swaggerwso2 API Manager,通过swagger调用API时找不到java Restfull Endpoint
【发布时间】:2017-07-20 04:08:00
【问题描述】:

我使用 WSO2 API Manager 创建了一个 API,添加了我自己的 java Restful 服务作为端点。测试服务端点工作正常。 我正确订阅了 API,但是当使用招摇的方式调用 API 时,它会返回以下正文内容:

<!DOCTYPE html>
<html>
<head>
<title>Apache Tomcat/8.0.45 - Error report</title>
<style type="text/css">
H1 {
font-family:Tahoma,Arial,sans-serif;
color:white;
background-color:#525D76;
font-size:22px;
} 
H2 {
font-family:Tahoma,Arial,sans-serif;
color:white;
background-color:#525D76;
font-size:16px;
} 
H3 {
font-family:Tahoma,Arial,sans-serif;
color:white;
background-color:#525D76;
font-size:14px;
} 
BODY {
font-family:Tahoma,Arial,sans-serif;
color:black;
background-color:white;
} 
B {
font-family:Tahoma,Arial,sans-serif;
color:white;
background-color:#525D76;
} 
P {
font-family:Tahoma,Arial,sans-serif;
background:white;
color:black;
font-size:12px;
}
A {
color : black;
}
A.name {
color : black;
}
.line {
height: 1px; 
background-color: #525D76; 
border: none;
}
</style>
</head>
<body>
<h1>HTTP Status 406 - Not Acceptable</h1>
<div class="line"></div>
<p><b>type</b> Status report</p>
<p><b>message</b> <u>Not Acceptable</u></p>
<p><b>description</b> <u>The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.</u></p>
<hr class="line">
<h3>Apache Tomcat/8.0.45</h3>
</body>
</html>

应该返回一个 application/xml 媒体类型!

这是我调用api后大摇大摆的屏幕截图

这是直接从浏览器调用服务时的响应

我也将响应媒体类型更改为 application/json 但它仍然没有工作。

有人可以帮我解决这个问题吗?

【问题讨论】:

    标签: wso2 endpoint api-manager


    【解决方案1】:

    问题是message 部分位于endpoint 和实际request 的末尾。这使得下面的调用变成了

    http://localhost:8080/messanger/webapi/messages/messages/
    

    这是一个无效的 URL。

    解决方案很简单。从端点 URL 中删除 messages 部分。

    即端点 URL 应为 http://localhost:8080/messanger/webapi/

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多