I tried to consume a wcf webservice method on adf mobile by using java api as seen as below code snippet.
I tried to run on classical adf generic application by creating webservice proxy. Then i could get response properly. But when i consume webservice method on adfmobile i get http 501 error response. I have tried using drag and drop into amx page and execute binding action, result is same.
What might be the reason?
brgds
private boolean validateClient()
{
List pnames = new ArrayList();
List pvals = new ArrayList();
List ptypes = new ArrayList();
pnames.add("UserName");
pvals.add("test");
ptypes.add(String.class);
pnames.add("Password");
pvals.add("123");
ptypes.add(String.class);
pnames.add("DeviceID");
pvals.add("123456");
ptypes.add(String.class);
GenericType result = null;
try
{
ClientDetail clientDetail = null;
result = (GenericType)AdfmfJavaUtilities.invokeDataControlMethod("mlService", null, "ValidateClient", pnames, pvals, ptypes);
for (int i = 0; i < result.getAttributeCount(); i++)
{
// Get each individual GenericType instance that holds the attribute key-value pairs
GenericType entityGenericType = (GenericType)result.getAttribute(i);
clientDetail = (ClientDetail)GenericTypeBeanSerializationHelper.fromGenericType(ClientDetail.class, entityGenericType);
}
if (clientDetail != null)
{
if (clientDetail.getIsValidate().booleanValue())
return true;
else
AdfmfContainerUtilities.invokeContainerJavaScriptFunction("com.accmee.menu", "navigator.notification.alert",
new Object[] { "No access",
"No access: ", "Ok" });
} else
{
AdfmfContainerUtilities.invokeContainerJavaScriptFunction("com.accmee.menu", "navigator.notification.alert",
new Object[] { "No access",
"No access: ", "Ok" });
return false;
}
}
catch (AdfInvocationException aie)
{
if (AdfInvocationException.CATEGORY_WEBSERVICE.compareTo(aie.getErrorCategory()) == 0)
{
throw new AdfException("Error with the server. Please try later.", AdfException.ERROR);
}
aie.printStackTrace();
throw new AdfException("Uzak veri sağlayısı çağrılırken hata oluştu", AdfException.ERROR);
}
return false;
}
make sure the WSDL URL is accessible from inside the test environment of the app ( emulator or mobile device)
Related
I'm trying to use example where I was able to update custom policies mentioned in this example and deployed REST API mentioned.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using AADB2C.RBAC.Sample.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using System.Net.Http;
namespace AADB2C.RBAC.Sample.Controllers
{
[Route("api/[controller]/[action]")]
public class IdentityController : Controller
{
private readonly AppSettingsModel AppSettings;
// Demo: Inject an instance of an AppSettingsModel class into the constructor of the consuming class,
// and let dependency injection handle the rest
public IdentityController(IOptions<AppSettingsModel> appSettings)
{
this.AppSettings = appSettings.Value;
}
[HttpPost(Name = "IsMemberOf")]
public async Task<ActionResult> IsMemberOf()
{
string input = null;
// If not data came in, then return
if (this.Request.Body == null)
{
return StatusCode((int)HttpStatusCode.Conflict, new B2CResponseModel("Request content is null", HttpStatusCode.Conflict));
}
//Read the input claims from the request body
using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
{
input = await reader.ReadToEndAsync();
}
//string input = Request.Content.ReadAsStringAsync().Result;
//string content = "";
//System.Web.HttpContext.Current.Request.InputStream.Position = 0;
//using (var reader = new StreamReader(
// Request.InputStream, System.Text.Encoding.UTF8, true, 4096, true))
//{
// content = reader.ReadToEnd();
//}
////Rest
//System.Web.HttpContext.Current.Request.InputStream.Position = 0;
// Check input content value
if (string.IsNullOrEmpty(input))
{
return StatusCode((int)HttpStatusCode.Conflict, new B2CResponseModel("Request content is empty", HttpStatusCode.Conflict));
}
// Convert the input string into InputClaimsModel object
InputClaimsModel inputClaims = InputClaimsModel.Parse(input);
if (inputClaims == null)
{
return StatusCode((int)HttpStatusCode.Conflict, new B2CResponseModel("Can not deserialize input claims", HttpStatusCode.Conflict));
}
if (string.IsNullOrEmpty(inputClaims.objectId))
{
return StatusCode((int)HttpStatusCode.Conflict, new B2CResponseModel("User 'objectId' is null or empty", HttpStatusCode.Conflict));
}
try
{
AzureADGraphClient azureADGraphClient = new AzureADGraphClient(this.AppSettings.Tenant, this.AppSettings.ClientId, this.AppSettings.ClientSecret);
// Demo: Get user's groups
GraphGroupsModel groups = await azureADGraphClient.GetUserGroup(inputClaims.objectId);
// Demo: Add the groups to string collections
List<string> groupsList = new List<string>();
foreach (var item in groups.value)
{
groupsList.Add(item.displayName);
}
// Demo: Set the output claims
OutputClaimsModel output = new OutputClaimsModel() { groups = groupsList };
// Demo: Check if user needs to be a member of a security group
if (!string.IsNullOrEmpty(inputClaims.onlyMembersOf))
{
List<string> onlyMembersOf = inputClaims.onlyMembersOf.ToLower().Split(',').ToList<string>();
bool isMemberOf = false;
foreach (var item in output.groups)
{
if (onlyMembersOf.Contains(item.ToLower()))
{
isMemberOf = true;
break;
}
}
// Demo: Throw error if user is not member of one of the security groups
if (isMemberOf == false)
{
return StatusCode((int)HttpStatusCode.Conflict, new B2CResponseModel("You are not authorized to sign-in to this application.", HttpStatusCode.Conflict));
}
}
// Demo: Return the groups collection
return Ok(output);
}
catch (Exception ex)
{
if (ex.Message.Contains("Request_ResourceNotFound"))
{
return StatusCode((int)HttpStatusCode.Conflict, new B2CResponseModel("Can not read user groups, user not found", HttpStatusCode.Conflict));
}
return StatusCode((int)HttpStatusCode.Conflict, new B2CResponseModel("Can not read user groups", HttpStatusCode.Conflict));
}
}
}
}
So I have reached point where custom policy uses REST POST method to get the groups details but this code mentioned doesn't provide me group details as it goes to catch statement and throws can not read user groups.The problem here is I cannot use localhost to run the Rest API and hit the API through custom policy ,I tried using proxy but it gives me bad request.
return StatusCode((int)HttpStatusCode.Conflict, new B2CResponseModel("Can not read user groups", HttpStatusCode.Conflict));
Any help or example would be very helpful
Web app code is in the source code folder in the linked repo.
I'm running the Microsoft sample for Bing Entity Search using the SDK and (NOT the REST API.) I can.t figure out how to enter the location key/value pair, based on this documentation:
https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.cognitiveservices.search.entitysearch.entitiesoperationsextensions.search?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev15.query%3FappId%3DDev15IDEF1%26l%3DEN-US%26k%3Dk(Microsoft.Azure.CognitiveServices.Search.EntitySearch.EntitiesOperationsExtensions.Search);k(TargetFrameworkMoniker-.NETFramework,Version%3Dv4.7.2);k(DevLang-csharp)%26rd%3Dtrue&view=azure-dotnet
I would like to continue to use named parameters so I can still do this:
var restaurants = client.Entities.Search(query: currentQuery, location: lat:? long:?);
The method with the query and location from the Microsoft sample will look like this:
public static void MultipleCurrentQueryLookup(string subscriptionKey)
{
var client = new EntitySearchClient(new ApiKeyServiceClientCredentials subscriptionKey));
try
{
string currentQuery = Settings1.Default.CurrentQuery;
var restaurants = client.Entities.Search(query: currentQuery,
location: "lat:47.623, long:-122.361, re:380m");
if (restaurants?.Places?.Value?.Count > 0)
{
// get all the list items that relate to this query
var listItems = restaurants.Places.Value.Where(thing => thing.EntityPresentationInfo.EntityScenario == EntityScenario.ListItem).ToList();
if (listItems?.Count > 0)
{
var sb = new StringBuilder();
foreach (var item in listItems)
{
var place = item as Place;
if (place == null)
{
Console.WriteLine("Unexpectedly found something that isn't a place named \"{0}\"", item.Name);
continue;
}
sb.AppendFormat(",{0} ({1}) {2}", place.Name, place.Telephone, place.Url);
}
Console.WriteLine("Ok, we found these places: ");
Console.WriteLine(sb.ToString().Substring(1));
}
else
{
Console.WriteLine("Couldn't find any relevant results for \"The Current Query\"");
}
}
else
{
Console.WriteLine("Didn't see any data..");
}
}
catch (ErrorResponseException ex)
{
Console.WriteLine("Encountered exception. " + ex.Message);
}
}
Having the following URL
https://test.sharepoint.com/shared%20documents/MyFolder1/myImg1.jpeg
I need to send a request for parent URL of this item (in this specific case image) and to get a response:
https://test.sharepoint.com/shared%20documents/MyFolder1/
Does such a request exists if using a CSOM or Office 365 Activity API?
Where in documentation can i find such examples?
static public string ReturnFileParentUrl(string url)
{
try
{
Uri uri = new Uri("https://XXX.sharepoint.com/");
using (var ctx = GetContext(uri, "YYY#DOMAIN.com", "password"))
{
Microsoft.SharePoint.Client.File item = ctx.Web.GetFileByServerRelativeUrl(url);
ctx.Load(item);
ctx.ExecuteQuery();
Console.WriteLine("file: {0}\n", item.Name);
Console.WriteLine("Type: {0}\n", item.TypedObject.ToString());
if (item.TypedObject.ToString() == "Microsoft.SharePoint.Client.File") //To check if there is a better way to check if the item is a file
if (item.ServerObjectIsNull != true)
{
ctx.Load(item, i => i.ListItemAllFields);
ctx.ExecuteQuery();
var folder = ctx.Web.GetFolderByServerRelativeUrl((string)item.ListItemAllFields["FileDirRef"]);
ctx.Load(folder);
ctx.ExecuteQuery();
Console.WriteLine("parent relative url {0}\n", folder.ServerRelativeUrl);
return folder.ServerRelativeUrl;
}
return null;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return null;
}
I try to get a related entity and get this error: Object reference not set to an instance of an object.
See below my code:
public IEnumerable<RUBAnnotation> GetAnnotationsByServiceRequestId(string serviceRequestId)
{
List<Annotation> annotationList = new List<Annotation>();
try
{
using (OrganizationServiceProxy organizationProxy = new OrganizationServiceProxy(organisationWebServiceUri, null, userCredentials, deviceCredentials))
{
organizationProxy.EnableProxyTypes();
var service = (IOrganizationService)organizationProxy;
OrganizationServiceContext orgContext = new OrganizationServiceContext(service);
Relationship rel = new Relationship("Incident_Annotation");
// get all incidents by incidentId
IEnumerable<Incident> incidents = from c in orgContext.CreateQuery<Incident>()
where c.Id == new Guid(serviceRequestId)
select c;
return GetAnnotationsEntities(incidents);
}
}
catch (Exception)
{
throw;
}
return null;
}
private List<RUBAnnotation> GetAnnotationsEntities(IEnumerable<Incident> incidents)
{
List<RUBAnnotation> annotationsList = new List<RUBAnnotation>();
try
{
foreach (Incident incident in incidents)
{
foreach (var annotation in incident.Incident_Annotation) // HERE OCCURS THE EXCEPTION!!
{
if (!string.IsNullOrEmpty(annotation.NoteText))
{
var customAnnotation = new RUBAnnotation();
customAnnotation.Id = annotation.Id.ToString();
if (annotation.Incident_Annotation != null)
{
customAnnotation.ServiceRequestId = annotation.Incident_Annotation.Id.ToString();
}
customAnnotation.Message = annotation.NoteText;
customAnnotation.CreatedOn = (DateTime)annotation.CreatedOn;
customAnnotation.UserId = annotation.CreatedBy.Id.ToString();
annotationsList.Add(customAnnotation);
}
}
}
}
catch (Exception e)
{
throw e;
}
return annotationsList;
}
Why do I get this error when I try to get incident.Incident_Annotation ? I think incident.Incident_Annotation is NULL, but why? Al my incidents have minimal 1 or more annotations.
Related entities must be explicitly loaded, you can find more information on this MSDN article:
MSDN - Access Entity Relationships
This is for a internal portal , and I am looking for a widget that allows user to login to their gmail account and view their account. I tried the Google gadget but it shows the following error
"this is a builtin module, so the UserPrefs and Content are ignored."
also since gadgets are gonna be discontinued I am uncomfortable using that as a long term solution.
Even widget from widgetbox, netvibes etc. don't seem to be working.
Is it because there has been some policy change by Google preventing these widgets from working ? or am i doing something wrong.
I also tried to use the Google widgets in a my site, but unfortunalitly it doesn't work.
It gives the Content are ignored.
No widgets haven't work for my code.
I think there is a policy change in it. But i didn't have any clew about it.
When you say 'login to their account' and what you want to do. You can use OAuth where a user grants your application permission to access their account.
Google have their own library written in a number of languages - some examples using Java, Python and PHP can be found here: https://developers.google.com/google-apps/gmail/xoauth2_libraries
When you use OAuth you register with Google and they give you a ConsumerKey and ConsumerSecret - this is what identifies you application to Google.
Once you do that provide a link to allow them to login - this will take them to a Google login, they login with their account - then they grant permission.
I've had problems using OAuth with GMail but successfully managed it with say their Contacts. For example this is the code I am using to retrieve all a users contacts
public List<Person> GetContacts()
{
OAuthParameters parameters = null;
GOAuthRequestFactory requestFactory = null;
ContactsService service = null;
ContactsQuery feedQuery = null;
ContactsFeed feed = null;
List<Person> contacts = null;
try
{
if (ConsumerKey == String.Empty) throw new ValueIsEmptyOrNullException("ConsumerKey");
if (ConsumerSecret == String.Empty) throw new ValueIsEmptyOrNullException("ConsumerSecret");
if (OAuthCallback == String.Empty) throw new ValueIsEmptyOrNullException("OAuthCallback");
if (SignatureMethod == String.Empty) throw new ValueIsEmptyOrNullException("SignatureMethod");
if (ApplicationName == String.Empty) throw new ValueIsEmptyOrNullException("ApplicationName");
if (Token == String.Empty) throw new ValueIsEmptyOrNullException("Token");
if (Nonce == String.Empty) throw new ValueIsEmptyOrNullException("Nonce");
if (Verifier == String.Empty) throw new ValueIsEmptyOrNullException("Verifier");
if (Scope == String.Empty)
Scope = "https://www.google.com/m8/feeds";
parameters = new OAuthParameters();
parameters.ConsumerKey = ConsumerKey;
parameters.ConsumerSecret = ConsumerSecret;
parameters.Scope = Scope;
parameters.Callback = OAuthCallback;
parameters.SignatureMethod = SignatureMethod;
parameters.Timestamp = Toolbox.GenerateTimeStamp();
parameters.Token = Token;
parameters.TokenSecret = TokenSecret;
parameters.Nonce = Nonce;
parameters.Verifier = Verifier;
requestFactory = new GOAuthRequestFactory("c1", ApplicationName, parameters);
service = new ContactsService(ApplicationName);
service.RequestFactory = requestFactory;
feedQuery = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));
feed = service.Query(feedQuery);
if (feed.Entries.Count > 0)
{
contacts = new List<Person>();
foreach (ContactEntry contact in feed.Entries)
{
try
{
if (contact.Name != null)
{
Person person = new Person();
int idStart = contact.Id.Uri.ToString().LastIndexOf('/');
if (idStart > 0)
{
person.PersonId = contact.Id.Uri.ToString().Substring(contact.Id.Uri.ToString().LastIndexOf('/') + 1);
}
else
{
person.PersonId = contact.Id.Uri.ToString();
}
person.GivenName = contact.Name.GivenName;
person.Surname = contact.Name.FamilyName;
person.Birthday = contact.Birthday;
person.Initials = contact.Initials;
person.Location = contact.Location;
person.MaidenName = contact.MaidenName;
person.Occupation = contact.Occupation;
person.Photograph = contact.PhotoUri.ToString();
person.Surname = contact.Name.FamilyName;
if (contact.Emails.Count > 0)
person.Email = contact.Emails[0].Address;
contacts.Add(person);
}
}
catch (System.Exception ex)
{
throw ex;
}
finally
{
}
}
}
}
catch (Exception ex)
{
throw ex;
}
return contacts;
}