I'm writting an Android App and connect to Azure Service bus - Topic. I write code to connect to existing namespace like this tutorial https://azure.microsoft.com/en-us/documentation/articles/service-bus-java-how-to-use-topics-subscriptions/
Configuration config = ServiceBusConfiguration.configureWithSASAuthentication(
"HowToSample",
"RootManageSharedAccessKey",
"SAS_key_value",
".servicebus.windows.net"
);
ServiceBusContract service = ServiceBusService.create(config);
But it throw an exception at ServiceBusContract service = ServiceBusService.create(config);.
It said "java.lang.RuntimeException: Service or property not registered: com.microsoft.windowsazure.services.serviceBus.ServiceBusContract
I looked up some way to fix it but not ok. So i use REST API to connect same this tutorial
REST API AZURE
It can run and sent message to Azure Service Bus - Topic. Now i want to write a method use to get message from this Topic's Subcription. Use Rest API like that
String url = "https://smarthomethesis.servicebus.windows.net/light_1/Subscriptions/LightSubscription/messages/head?timeout=60";
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(url);
// Add header
String token = generateSasToken(new URI(uri));
get.setHeader("Authorization", token);
System.out.println("Llamando al post");
HttpResponse response = client.execute(get);
HttpEntity entity = response.getEntity();
String responseString = EntityUtils.toString(entity, "UTF-8");
But it can't get message, responseString show
"<Error><Code>400</Code><Detail>The request is not supported for the supplied api-version ''. TrackingId:d7624c10-4fc9-43d6-b092-880947e3b820_G31,TimeStamp:1/10/2016 3:43:44 PM</Detail></Error>"
I don't know why it isn't supported. Can you help me. Thank you