Java 如何使用Olingo(Odata)进行HTTP身份验证服务调用
我有一个Web服务可以访问,它受到基本HTTP身份验证的保护 如何设置ODataClient以向web服务发送身份验证Java 如何使用Olingo(Odata)进行HTTP身份验证服务调用,java,odata,http-authentication,olingo,Java,Odata,Http Authentication,Olingo,我有一个Web服务可以访问,它受到基本HTTP身份验证的保护 如何设置ODataClient以向web服务发送身份验证 ODataClient client = ODataClientFactory.getClient(); String iCrmServiceRoot = "https://example.dev/Authenticated/Service"; ODataServiceDocumentRequest odClientReq = client.getRetrieveR
ODataClient client = ODataClientFactory.getClient();
String iCrmServiceRoot = "https://example.dev/Authenticated/Service";
ODataServiceDocumentRequest odClientReq =
client.getRetrieveRequestFactory().getServiceDocumentRequest(iCrmServiceRoot);
要访问web服务,只需将基本HTTP身份验证添加到配置中,如下所示:
ODataClient client = ODataClientFactory.getClient();
// add the configuration here
client.getConfiguration()
.setHttpClientFactory(new BasicAuthHttpClientFactory("[username]", "[password]"));
String iCrmServiceRoot = "https://example.dev/Authenticated/Service";
ODataServiceDocumentRequest odClientReq =
client.getRetrieveRequestFactory().getServiceDocumentRequest(iCrmServiceRoot)