I am developing a small application using Xamarin forms, I would like to implement (MSAL) active directory, I have configured everything and getting token, after that I have checked in postman while I am getting below
{"success": false," message": "Sorry, you are not authorized to access this API. Please make sure you are logged in!","data":null}
I tried sending the web request to server while I am getting HTTP response below
{StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.HttpConnection+HttpConnectionResponseContent, Headers: { Transfer-Encoding: chunked Server: Kestrel WWW-Authenticate: Bearer error="invalid_token", error_description="The signature is invalid" X-Rate-Limit-Limit: 12h X-Rate-Limit-Remaining: 4999 X-Rate-Limit-Reset: 2021-07-19T14:20:05.8546118Z Date: Mon, 19 Jul 2021 02:20:05 GMT Content-Type: text/plain }}
Here I tried the code below, please help me to resolve this issue
App.xaml.cs
public static IPublicClientApplication PCA = null;
public static string[] Scopes = { "User.Read" };
PCA = PublicClientApplicationBuilder.Create(Constants.ClientID)
.WithRedirectUri($"msauth://{Constants.AppId}/{Constants.SIGNATURE_HASH}")
.WithAuthority($"https://login.microsoftonline.com/{Constants.TenentID}")
.Build();
Viewmodel signin command i called SignInAsync
public async Task SignInAsync()
{
Microsoft.Identity.Client.AuthenticationResult authResult = null;
IEnumerable<IAccount> accounts = await App.PCA.GetAccountsAsync().ConfigureAwait(false);
try
{
IAccount firstAccount = accounts.FirstOrDefault();
authResult = await App.PCA.AcquireTokenSilent(App.Scopes, firstAccount)
.ExecuteAsync();
Session.Instance.TokenValueFromApp = authResult.AccessToken;
}
catch (MsalUiRequiredException)
{
try
{
authResult = await App.PCA.AcquireTokenInteractive(App.Scopes) .WithParentActivityOrWindow(App.ParentWindow)
.ExecuteAsync();
Session.Instance.TokenValueFromApp = authResult.AccessToken;
}
catch (Exception ex2)
{
}
}
}
Mainactivity.cs
App.ParentWindow = this;
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);
}
Manifest.xml
<application android:label="#string/app_name" android:icon="#mipmap/icon">
<activity android:name="microsoft.identity.client.BrowserTabActivity" android:configChanges="orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="msal{clientid}" android:host="auth" /> //here i am pasting client id
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="msauth" android:host="{bundleid}" android:path="/{signaturehash}" /> //here i am pasting bundle id and signature hash
</intent-filter>
</activity>
</application>
<queries>
<package android:name="com.azure.authenticator" />
<package android:name="{bundle id}" /> // here i am pasting a bundle id
<package android:name="com.microsoft.windowsintune.companyportal" />
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
</intent>
<intent>
<action android:name="android.support.customtabs.action.CustomTabsService" />
</intent>
</queries>
Related
We need to capture Oozie workflow Failure events in Splunk - HTTP Event Collector (Example: https://qa.splunk.organization.com/services/collector).
To achieve this, we created a separate Oozie Java action to log the failure event to Splunk. The problem with this approach is, we have more than 100 oozie workflows and adding a new workflow action for Splunk is not feasible.
Is there any better approach to capture Oozie workflow failure in Splunk HTTP Event Collector?
Workflow.xml
<start to="Input_Check" />
<decision name="Input_Check">
<switch>
<case to="Input_Move"> ${fs:dirSize(source_hdfs_path) gt 0} </case>
<default to="end"/>
</switch>
</decision>
<action name="Input_Move">
<java>
<main-class>com.org.FileMove</main-class>
<arg>${source_hdfs_path}/</arg>
<arg>${destination_hdfs_path}</arg>
</java>
<ok to="Process_File" />
<error to="Splunk_Log" />
</action>
<action name="Process_File">
<java>
<main-class>com.org.FileProcessor</main-class>
<arg>inputPath=${destination_hdfs_path}/</arg>
<arg>outputPath=${output_hdfs_path}/</arg>
</java>
<ok to="end" />
<error to="Splunk_Log" />
</action>
<action name="Splunk_Log">
<java>
<main-class>com.org.SplunkLog</main-class>
<arg>https://qa.splunk.organization.com/services/collector</arg>
<arg>auth-token</arg>
<arg>Workflow Failed</arg>
</java>
<ok to="fail"/>
<error to="fail"/>
</action>
<kill name="fail">
<message>Test Splunk Workflow failed</message>
</kill>
<end name="end" />
</workflow-app>
Java Class
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
public class SplunkLog {
public static void main(String[] args) throws Exception {
if(args.length!=3){
System.exit(-1);
}
String URL = args[0];
String authToken = args[1];
String data = args[2];
String jsonData = "{\"event\": \"" + data + "\", \"sourcetype\": \"manual\"}";
URL url = new URL (URL);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
connection.setRequestProperty ("Authorization", "Splunk " + authToken);
connection.setRequestMethod("POST");
connection.connect();
OutputStream outputStream = connection.getOutputStream();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
writer.write(jsonData);
writer.close();
outputStream.close();
if (connection.getResponseCode()==HttpURLConnection.HTTP_OK) {
System.out.println("SUCCESS");
}else{
System.out.println("data : " + jsonData + "token : " + authToken);
System.out.println("ERROR : " + connection.getResponseMessage());
}
}
}
my requirement is to get latitude and longitude from gps, it was working find until I updated the NuGet packages and android sdk. Even if location services are on still I can't access the location.
var locator = CrossGeolocator.Current;
if (locator.IsGeolocationEnabled)
{
locator.DesiredAccuracy = 15;
var position = await
locator.GetPositionAsync(TimeSpan.FromMilliseconds(3000));
Latitude = position.Latitude;
Longitude = position.Longitude;
}
Here if statement returns always false.
My AndroidManifest looks like this..
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.ZameeliNew" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<application android:label="ZameeliNew.Android" android:usesCleartextTraffic="true" android:icon="#drawable/iconBase">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyBExspvDUbXly-g3YNQdUdnONRSEaHoiNw" />
<uses-library android:name="org.apache.http.legacy" android:required="false" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>
You are probably using outdated repo with xamarin forms > 4.0. This project was moved to Xamarin.Essentials. I strongly recommend to use this one.
Then in your code you can use for example
internal static async Task<Location> GetDeviceLocation()
{
try
{
var request = new GeolocationRequest(GeolocationAccuracy.Medium);
var location = await Geolocation.GetLocationAsync(request);
return location;
}
catch (Exception ex)
{
Helpers.ShowError("could not locate device: " + ex.Message, 6000);
}
return null;
}
Don't forget to initialize component first.
To check device exceptions:
try
{
var location = await Geolocation.GetLastKnownLocationAsync();
if (location != null)
{
Console.WriteLine($"Latitude: {location.Latitude}, Longitude: {location.Longitude}, Altitude: {location.Altitude}");
}
}
catch (FeatureNotSupportedException fnsEx)
{
// Handle not supported on device exception
}
catch (FeatureNotEnabledException fneEx)
{
// Handle not enabled on device exception
}
catch (PermissionException pEx)
{
// Handle permission exception
}
catch (Exception ex)
{
// Unable to get location
}
I've inherited a Xamarin Android project that uses push notifications. The project was using the Google Client Messaging package, I am in the process of converting to the Firebase Messaging package. But I've noticed that there is no .register method for FireBaseMessaging. Do I still need to register with the sender id from the firebase console and if so how?
Old Code:
private void registerInBackground()
{
Task.Run(() =>
{
string msg = "";
try
{
if (gcm == null)
{
gcm = GoogleCloudMessaging.GetInstance(this);
}
regid = gcm.Register(Constants.SenderID);
msg = "Device registered, registration ID=" + regid;
Log.Info(TAG, msg);
// can use GCM/HTTP or CCS to send messages to your app.
sendRegistrationIdToBackend(regid);
// Persist the regID - no need to register again.
storeRegistrationId(this, regid);
}
catch (System.Exception ex)
{
msg = "Error :" + ex.Message;
Log.Error(TAG, msg);
}
finally
{
//RunOnUiThread(() => mDisplay.Append(msg + "\n"));
}
return msg;
});
}
When I change to FireBaseMessaging I notice that on the line regid = gcm.Register(Constants.SenderID); there is no register method on Firebase messaging. Any help would be greatly appreciated.
You don't need to call a register method it will automatically register. You just need to follow this steps:
Add google-services.json to the Android project and make sure to set the build action of that file as GoogleServicesJson.
Add the following in AndroidManifest.xml under application tag:
<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
Implement FirebaseInstanceIdService
[Service, IntentFilter(new[] { "com.google.firebase.INSTANCE_ID_EVENT" })]
public class MyFirebaseInstanceIdService : FirebaseInstanceIdService
{
public override void OnTokenRefresh()
{
var token = FirebaseInstanceId.Instance.Token;
//send token to server here.
}
}
I made a WCF restful service for uploading the files to specific directory on the server, and a small ASP.NET web application that can upload the files threw this web service. The problem is that I am constantly getting the error of access denied. I tried to give all the privileges to a folder for testing purposes (Full control for Everyone, Full control for IIS_IUSRS, AppPool of WCF and Web service, etc.), but still the same error shows. Below is the code of Service and Web application:
Main WCF service class
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple,
InstanceContextMode = InstanceContextMode.PerCall,
IgnoreExtensionDataObject = true,
IncludeExceptionDetailInFaults = true)]
public class UploadFile : IUploadFile
{
public ReturnValue ExcelUpload(Stream File)
{
using (FileStream writer = new FileStream(#"C:\Users\Public\Documents", FileMode.Create))
{
int ReadCount = 0;
var buffer = new byte[8192];
while ((ReadCount = File.Read(buffer, 0, buffer.Length)) != 0)
{
writer.Write(buffer, 0, ReadCount);
}
}
return new ReturnValue() { IsSuccessfull = true };
}
public ReturnValue test(int id)
{
return new ReturnValue() { IsSuccessfull = true };
}
}
WCF service contract
[ServiceContract(Name = "ExcelUpload.IUploadFile")]
public interface IUploadFile
{
[OperationContract]
[DataContractFormat]
[WebInvoke(Method = "*",
UriTemplate = "UploadExcel/",
BodyStyle = WebMessageBodyStyle.Bare,
ResponseFormat = WebMessageFormat.Json)]
ReturnValue ExcelUpload(Stream File);
// TODO: Add your service operations here
[OperationContract]
[DataContractFormat]
[WebInvoke(Method = "POST",
UriTemplate = "test/",
BodyStyle = WebMessageBodyStyle.Bare,
ResponseFormat = WebMessageFormat.Json)]
ReturnValue test(int id);
}
// Use a data contract as illustrated in the sample below to add composite types to service operations.
[DataContract]
public class ReturnValue
{
[DataMember]
public bool IsSuccessfull { get; set; }
}
WCF service web.config
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
<serviceActivations>
<add relativeAddress="~/UploadFile.svc" service="ExcelUpload.UploadFile"/>
</serviceActivations>
</serviceHostingEnvironment>
<bindings>
<webHttpBinding>
<binding name="crossDomain"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
transferMode="Streamed"
sendTimeout="00:05:00"
crossDomainScriptAccessEnabled="true">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="defaultServiceBehaviour">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="100" maxConcurrentSessions="100"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="defaultEndpointBehaviour">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="ExcelUpload.UploadFile" behaviorConfiguration="defaultServiceBehaviour">
<endpoint address="" behaviorConfiguration="defaultEndpointBehaviour" bindingConfiguration="crossDomain" binding="webHttpBinding" contract="ExcelUpload.IUploadFile"></endpoint>
</service>
</services>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
<add binding="basicHttpBinding" scheme="http"/>
</protocolMapping>
</system.serviceModel>
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="true"/>
</authentication>
<requestFiltering allowHighBitCharacters="true">
<verbs allowUnlisted="false">
<add verb="POST" allowed="true"/>
<add verb="GET" allowed="true"/>
</verbs>
</requestFiltering>
</security>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
Web application
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="UploadTest.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Uploading using WCF REST API</title>
<script type="text/javascript">
function uploadBlobOrFile(blobOrFile) {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://intranet-services.tosama.si/CroSalesExcelUpload/UploadFile.svc/UploadExcel/', true);
xhr.setRequestHeader('Content-length', blobOrFile.size);
xhr.onload = function (e) {
progressBar.value = 0;
progressBar.textContent = progressBar.value;
};
// Listen to the upload progress.
var progressBar = document.querySelector('progress');
xhr.upload.onprogress = function (e) {
if (e.lengthComputable) {
progressBar.value = (e.loaded / e.total) * 100;
progressBar.textContent = progressBar.value; // Fallback.
}
};
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
alert(xhr.responseText);
}
};
xhr.send(blobOrFile);
}
</script>
</head>
<body>
<input id="filePicker" type="file" name="Package" accept="image/*"/>
<br />
<progress min="0" max="100" value="0">0% complete</progress>
<br />
<button title="upload"
onclick="if (filePicker.files[0]) uploadBlobOrFile(filePicker.files[0])">
<span>Upload</span>
</button>
</body>
</html>
Very basic thing is, why are you trying to create object for directory?
#"C:\Users\Public\Documents"
try changing to #"C:\Users\Public\Documents\MyFile.txt"
Here you can use any type of file instead of txt.
And don't forget to set limits for your file to be uploaded.
Hope it helps.. !
I am using asp.net. I have created an WCF service in C# and hosted on IIS server. I am calling this service using JQuery in my asp.net web application. When I called the service using JQuery, it is going to error function and in alert there is empty message.
Calling service form .aspx page.
<script src="Script/jquery-1.10.2.min.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
function callService()
{
var value = 10;
$.ajax({
type: "POST",
url: "http://localhost/IISWCF/Service1.svc/getdata",
contentType: "application/json; charset=utf-8",
data: '{"value": "' + value + '"}',
dataType: "json",
processdata: true, //True or False
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("error: " + errorThrown);
},
success: function(msg) {
alert(msg.d);
}
});
}
</script>
<script type="text/javascript" language="javascript">
$(document).ready(function(){
callService();
})
</script>
Service1.svc file
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
}
IService1.cs file
namespace WcfService1
{
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json)]
string GetData(int value);
}
}
WCF Web.config file
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService1.Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="EndpBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior">
<endpoint behaviorConfiguration="EndpBehavior" address="" binding="webHttpBinding" contract="WcfService1.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
Please help me to resolved this issue.
I have added some dummy code, probably few methods are not used also. But you can test your code with the dummy DoubleUp method. Also, you have defined endpointbehavior, but is it used, it should be applied to endpoint and its important. Ref my example below.
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
[ServiceContract]
public interface ICalculatorService
{
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "/DoubleUp/{val}")]
int DoubleUp(string val);
[OperationContract]
[WebGet(ResponseFormat=WebMessageFormat.Json, UriTemplate="/{value}/{value1}")]
int AddValues(string value, string value1);
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json)]
string ConcatenateString(string stringArray);
}
public class CalculationService : ICalculatorService
{
public int DoubleUp(string val)
{
return 2 * Convert.ToInt32(val);
}
public int AddValues(string value, string value1)
{
return Convert.ToInt32(value) + Convert.ToInt32(value1);
}
public string ConcatenateString(string stringArray)
{
string returnString = string.Empty;
returnString += stringArray;
return returnString;
}
}
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="JSONBinding"></binding>
</webHttpBinding>
<basicHttpBinding>
<binding name="basicHTTP">
<security mode="None">
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="basicBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="JSON">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="RestWCFService.CalculationService" behaviorConfiguration="basicBehavior">
<endpoint address="basic" binding="basicHttpBinding" contract="RestWCFService.ICalculatorService" bindingName ="basicHTTP"></endpoint>
<endpoint behaviorConfiguration="JSON" binding="webHttpBinding" bindingConfiguration="JSONBinding" contract="RestWCFService.ICalculatorService" name="JSONService"></endpoint>
</service>
</services>
<protocolMapping>
<add binding="basicHttpBinding" scheme="http"/>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
/* This is the code for accessing the service via REST call
WebClient client = new WebClient();
string s = client.DownloadString("http://localhost/RestWCFService/CalculationService.svc/DoubleUp/3");
Console.WriteLine("Response returned is:" + s);
*/
/*This is the section to access service via Proxy */
ChannelFactory<RestWCFService.ICalculatorService> client = new ChannelFactory<RestWCFService.ICalculatorService>();
client.Endpoint.Address = new EndpointAddress("http://localhost/RestWCFService/CalculationService.svc/basic");
client.Endpoint.Binding = new BasicHttpBinding();
RestWCFService.ICalculatorService service = client.CreateChannel();
int val = service.DoubleUp("2");
((IClientChannel)service).Close();
client.Close();
Console.WriteLine("Values returned is:" + val.ToString());
/*Programmatic access ends here */
Console.ReadLine();
Your service is working fine. Made some changes.
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate="/GetData?value={value}")]
string GetData(int value);
}
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
}
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService1.Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="EndpBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior">
<endpoint behaviorConfiguration="EndpBehavior" address="" binding="webHttpBinding" contract="WcfService1.IService1">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Access the service on browser and you get the result.
http://localhost/IISWCF/Service1.svc/GetData?value=1
If your service is working fine, then try this JS as your JS is incorrect for this service request.
<script type="text/javascript" language="javascript">
function callService() {
var value = 10;
$.ajax({
type: "GET",
url: "http://localhost/IISWCF/Service1.svc/GetData?value=1",
contentType: "application/json; charset=utf-8",
data: '{"value": "' + value + '"}',
dataType: "text",
processdata: false, //True or False
statusCode: {
404: function () {
alert("page not found");
},
200: function () {
alert('HTTP HIT WAS Good.');
},
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("error: " + errorThrown);
},
success: function (msg) {
alert(msg);
}
});
}