Skip to Content
0
Former Member
May 21, 2015 at 03:07 PM

Android Native onlinestore Get Request not working

15 Views

I have increased time, now i am getting "com.sap.smp.client.odata.exception.ODataNetworkException: Unknown network error occured"

Here is my code snippet:

private boolean OpenOnlineStore(Context context) throws OnlineODataStoreException

{

AgencyOpenListener openListener = AgencyOpenListener.getInstance();

if (openListener.getStore() == null) {

LogonCoreContext lgCtx = lgCore.getLogonContext();

//Set host

lgCtx.setHost("xxx.xx.xx.x");

lgCtx.setSecurtityConfig("admin");

lgCtx.setDomain("default");

//Set port

int port = 8080;

lgCtx.setPort(port);

//Set whether the registration uses secure connection or not

lgCtx.setHttps(false);

//set user creation policy

UserCreationPolicy ucPolicy = UserCreationPolicy.automatic;

lgCtx.setUserCreationPolicy(ucPolicy);

try {

lgCtx.setBackendUser("username");

lgCtx.setBackendPassword("password");

} catch (LogonCoreException e) {

//Notifies the execution finished

Log.e(TAG, "error entering user credentials", e);

}

CredentialsProvider credProvider = CredentialsProvider

.getInstance(lgCtx);

HttpConversationManager manager = new CommonAuthFlowsConfigurator(

context).supportBasicAuthUsing(credProvider).configure(

new HttpConversationManager(context));

// XCSRFTokenRequestFilter implements IRequestFilter

// Request filter that is allowed to preprocess the request before

// sending

XCSRFTokenRequestFilter requestFilter = XCSRFTokenRequestFilter

.getInstance(lgCtx);

XCSRFTokenResponseFilter responseFilter = XCSRFTokenResponseFilter

.getInstance(context, requestFilter);

manager.addFilter(requestFilter);

manager.addFilter(responseFilter);

// Method to open a new online store asynchronously

try {

String endPointURL = lgCtx.getAppEndPointUrl();

Log.v(TAG, "End URL : " + endPointURL);

URL url = new URL(endPointURL);

OnlineODataStore.OnlineStoreOptions option = new OnlineStoreOptions();

option.format = PayloadFormatEnum.XML;

option.forceMetadataDownload = true;

option.useCache = true;

//

option.cacheEncryptionKey = "secret";

OnlineODataStore.open(context, url, manager, openListener,

option);

openListener.waitForCompletion();

if (openListener.getError() != null) {

throw openListener.getError();

}

} catch (ODataContractViolationException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (LogonCoreException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (MalformedURLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

// Check if OnlineODataStore opened successfully

OnlineODataStore store = openListener.getStore();

if (store != null) {

return true;

} else {

return false;

}

} else {

return true;

}

// End

}