当使用 REST api 使用 jersey java REST 客户端访问 WSO2 DAS 时,我将响应作为不受支持的媒体类型,响应状态为 415 和响应
InboundJaxrsResponse{context=ClientResponse{method=POST, uri= https://localhost:9443/analytics/search , status=415, reason=Unsupported Media Type}}
下面的客户端来源。任何人都可以帮助解决这个问题。
package com.rilfi.research.c2c.das.rest.client;
import org.glassfish.jersey.SslConfigurator;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import javax.net.ssl.SSLContext;`enter code here`
import javax.ws.rs.client.*;
import javax.ws.rs.core.*;
public class DasClientApp {
public static void main(String[] args) {
SslConfigurator sslConfig = SslConfigurator.newInstance()
.trustStoreFile("./client-truststore.jks")
.trustStorePassword("wso2carbon")
.keyStoreFile("wso2carbon.jks")
.keyPassword("wso2carbon");
SSLContext sslContext = sslConfig.createSSLContext();
Client client = ClientBuilder.newBuilder().sslContext(sslContext).build();
WebTarget webTarget = client.target("https://localhost:9443").path("analytics/search");
MultivaluedMap<String, String> formData = new MultivaluedHashMap<String, String>();
formData.add("tableName", "V1SALEFULL3");
formData.add("query", "product:phone");
formData.add("start", "0");
formData.add("count", "10");
Response response = webTarget.request(MediaType.APPLICATION_JSON).post(Entity.form(formData));
System.out.println(response.getStatus());
System.out.println(response.readEntity(String.class));
System.out.println(response);
}
}