Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all articles
Browse latest Browse all 555

Web Config syntax errors

$
0
0

I am getting the following errors in syntax... can you help? Using VS 2015 and NET Framework 4.5

++++++++++++++++++ web.config file ++++++++++++++++++++++++++++

<?xml version="1.0"?>
<configuration>

<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
</httpModules>
</system.web>
<system.serviceModel>
<services>
<service name="WcfRestBased.Service1"

++++++++++++ error here... The 'behaviorConfiguration' attribute is invalid. The value 'myService1Behavior' is invalid according to its datatype
'serviceBehaviorConfigurationType' - the Enumeration constraint failed. +++++++++++++++++++++

behaviorConfiguration="myService1Behavior">

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

<endpoint name="webHttpBinding"

address=""

binding="webHttpBinding"

contract="WcfRestBased.IService1"

++++++++++++ and error here... The 'behaviorConfiguration' attribute is invalid. The value 'webHttp' is invalid according to its datatype
'endpointBehaviorConfigurationType' - the Enumeration constraint failed. +++++++++++++++++++++

behaviorConfiguration="webHttp"

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

>
</endpoint>
<endpoint name="mexHttpBinding"

address="mex"

binding="mexHttpBinding"

contract="IMetadataExchange"

/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 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>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="ApplicationInsightsWebTracking"/>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
preCondition="managedHandler"/>
</modules>
<!--
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"/>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>

</configuration>

++++++++++++++++++++++++++++++++++++ IService1.cs +++++++++++++++++++++++++++++++++++

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace WcfRestBased
{
// 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 IService1
{

[OperationContract(Name = "PostSampleMethod")]
[WebInvoke(Method = "POST",
UriTemplate = "PostSampleMethod/New")]
string PostSampleMethod(Stream data);

[OperationContract(Name = "GetSampleMethod")]
[WebGet(UriTemplate = "GetSampleMethod/inputStr/{name}")]
string GetSampleMethod(string name);
// TODO: Add your service operations here
}


// Use a data contract as illustrated in the sample below to add composite types to service operations.
[DataContract]
public class CompositeType
{
bool boolValue = true;
string stringValue = "Hello ";

[DataMember]
public bool BoolValue
{
get { return boolValue; }
set { boolValue = value; }
}

[DataMember]
public string StringValue
{
get { return stringValue; }
set { stringValue = value; }
}
}
}

+++++++++++++++++++++++++++++++ Service1.svc.cs ++++++++++++++++++++++++++++++++

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace WcfRestBased
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
// NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
public class Service1 : IService1
{
public string PostSampleMethod(Stream data)
{
// convert Stream Data to StreamReader
StreamReader reader = new StreamReader(data);
// Read StreamReader data as string
string xmlString = reader.ReadToEnd();
string returnValue = xmlString;
// return the XMLString data
return returnValue;
}
public string GetSampleMethod(string strUserName)
{
StringBuilder strReturnValue = new StringBuilder();
// return username prefixed as shown below
strReturnValue.Append(string.Format
("You have entered userName as {0}", strUserName));
return strReturnValue.ToString();
}
}


Viewing all articles
Browse latest Browse all 555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>