I trying host my project, but when I run svc file then i get exception.
Exception data: System.InvalidOperationException: The convention requires the use of Session, but the "BasicHttpBinding" binding is not supported or is not configured correctly.
What could be the problem?
I tried changing the web.config file but I don't know what the problem is
You can change your binding mode from BasicHttpBinding to WsHttpBinding. Since the default binding method for HTTP is BasicHttpBinding, you can modify it in the <System.ServiceModel>:
<protocolMapping>
<add scheme="http" binding="wsHttpBinding" bindingConfiguration="WsHttpSession"/>
</protocolMapping>
This allows you to modify the binding.
Related
The binding at system.serviceModel/bindings/webHttpBinding does not have a configured binding named 'webBinding'. This is an invalid value for bindingConfiguration.
there is a problem with your config, possibly you are trying to use webHttpBinding but didn't define any bindingConfiguration named webBinding in the bindings section.
something like -
<webHttpBinding>
<binding name="webBinding">
</binding>
</webHttpBinding>
I'm using WebApi 2.2 and have installed the WebApi 2.2 Tracing package.
In my WebApiConfig.Register method, I have added this line:
config.EnableSystemDiagnosticsTracing();
I'd like to write out some information to trace.axd in my action methods, like what I used to do with ASP.NET webform.
Something like:
[Route("getCurrentUser")]
[HttpPost]
public IHttpActionResult GetCurrentUser()
{
Trace.WriteLine("GetCurrentUser"); // doesn't work
Configuration.Services.GetTraceWriter().Warn(
Request, "AccountController", "GetCurrentUser"); // doesn't work either
}
However I'm not seeing anything in trace.axd.
I do see the info logged in visual studio though, when I debug it, but it's writing out too much information which I don't need.
What I really want is to only see the trace information I specifically write in my action methods.
Thanks!!
When you enable that, it creates a new instance of SystemDiagnosticsTraceWriter class. The default TraceLevel is Info so your Warn should work.
By default, the SystemDiagnosticsTraceWriter writes traces to System.Diagnostics.Trace and they are written in the Output window of the Visual Studio. So you should register additional Trace Listeners.
You should configure it in your web config where to write the tracing logic to?
I'm guessing the Trace.axd is the ASP.NET Trace Viewer and works with ASP.NET Pages. not sure whether it can work with Web API.
But you can configure a different trace listener e.g. to Event Log or Console, or File or your custom trace writer:
<system.diagnostics>
<trace autoflush="false" indentsize="4">
<listeners>
<add name="eventLogListener"
type="System.Diagnostics.EventLogTraceListener"
initializeData="TraceListenerLog" />
<add name="logFileListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="E:\CompressedLogs\Service1-WebApi-TraceOutput.log" />
<remove name="Default" />
</listeners>
</trace>
</system.diagnostics>
Great question, I'm choosing an Web API tracing component and the first one that pops to mind is ASP.NET Tracing, as it is easy to enable/disable and secure. There's no need to install additional packages; the ASP.NET Trace can be used through System.Web.HttpContext.Current:
using System.Web;
...
catch(Exception e)
{
HttpContext.Current.Trace.Warn("MyWebAPI", string.Format("[ERROR] {0}", e));
}
Remember to enable trace in web.config:
<trace enabled="true" pageOutput="false" localOnly="true" requestLimit="200" />
I aways use pageOutput="false" localOnly="true" because I think it's the most secure trace configuration (other than being disabled ;-): there's no trace output on the pages, and the trace can be viewed only by a browser running on the server.
If you need to view the trace on production enviroments, remember to turn it off after you use it.
This question already has answers here:
The type 'RestService.weddingservice', provided as the Service attribute value in the ServiceHost directive could not be found
(6 answers)
Closed 7 years ago.
The error is:
The type 'WF.XXX.WebServices.XXXXService', provided as the Service
attribute value in the ServiceHost directive, or provided in the
configuration element
system.serviceModel/serviceHostingEnvironment/serviceActivations could
not be found.
Stack Trace:
[InvalidOperationException: The type 'WF.XXX.WebServices.XXXXService',
provided as the Service attribute value in the ServiceHost directive,
or provided in the configuration element
system.serviceModel/serviceHostingEnvironment/serviceActivations could
not be found.]
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String
constructorString, Uri[] baseAddresses) +52742
System.ServiceModel.HostingManager.CreateService(String
normalizedVirtualPath) +1459
System.ServiceModel.HostingManager.ActivateService(String
normalizedVirtualPath) +44
System.ServiceModel.HostingManager.EnsureServiceAvailable(String
normalizedVirtualPath) +623
[ServiceActivationException: The service
'/XXXXX/XXXXXService/XXXXService.svc' cannot be activated due to an
exception during compilation. The exception message is: The type
'WF.XXX.WebServices.XXXXService', provided as the Service attribute
value in the ServiceHost directive, or provided in the configuration
element
system.serviceModel/serviceHostingEnvironment/serviceActivations could
not be found..] System.Runtime.AsyncResult.End(IAsyncResult result)
+687598 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult
result) +190
System.ServiceModel.Activation.ServiceHttpModule.EndProcessRequest(IAsyncResult
ar) +304662
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult
ar) +94
How to fix this error on the server?
Update on 9/18/2012:
I have Visual Studio 2012 and .NET Framework 4.5 installed on my machine but server has only .NET Framework 4.0. I am not sure if this matters, because I built the service with .NET Framework 4.0.
But strangely, I noticed a 4.5 feature when I run my project. It shows a URL to singleWSDL file, which is not available in .NET 4.0 version. Why does this show up when the project is built with .NET Framework 4.0? Here is the screenshot:
Update 9/19/12:
Here is the relavant web.config file:
<system.serviceModel>
<services>
<service name="XXXXService">
<!-- Use a bindingNamespace to eliminate tempuri.org -->
<endpoint address="" name="XXXXService"
binding ="basicHttpBinding"
bindingNamespace="#services.url#/XXXXService"
contract="WF.XXX.WebServices.XXXXService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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"/>
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode="None" mapClientCertificateToWindowsAccount="true" />
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
To answer your questions
(1) Make sure you have built your project and the the dll which contains the service type XXXXService is placed in the bin directory.
(2) Single Wsdl is a new 4.5 feature. Since 4.5 is an in-place upgrade of 4.0 you will get the benefit of ?SingleWsdl even if you target your project to 4.0. But when you deploy the same service on a machine with just 4.0 then you will not be able to get this. To get this on your service machine make sure you have 4.5 on that too.
Hope this helps.
Thanks!
I had the same problem and the cause was that I had changed the namespace in the code files IService1.cs and Service1.svc.cs but forgot to change the namespace in the Service1.svc file.
E.G. in service1.svc
< % # ServiceHost Service="WcfService2.Service1" % >
must be changed to:
< % # Service="NewNamespaceName.Service1" % >
You can build the solution without Visual Studio catching the typo error.
I had the same issue. In my case, simply deleting the bin and obj folders and rebuilding fixed the issue.
i am new to windows 8 metro application development , please let me help out in figuring out this issuse.
i want to consume web services in my metro application but the service reference url is dynamic.
i my app , the user will be given a provision to specify the url in a textbox , so i need to connect to that web service , that means the service reference url will be changing.
Till now i am connecting to web service in a traditional way like , giving a specific service reference by adding service reference and creating an instance and using that instance to call all the methods inside that web service .
but,
1) how should i consume web services if the service reference url is changing.
2)Access individual service methods inside that service (call that methods by passing some parameters as inputs).
Thanks in advance.
If you have the same service with different locations simply add it with "Add Service Reference..." and add the specified URL in the service client constructor:
var svc = new DataServiceClient("BasicHttpBinding_DataService",
"http://url.com/DataService.svc");
BasicHttpBinding_DataService is your (generated) binding name from the client config (automatically generated when doing "Add new Web Reference..."):
Example ServiceReferences.ClientConfig
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_DataService" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="TransportWithMessageCredential" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://localhost:44300/Services/DataService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_DataService"
contract="DataService.DataService" name="BasicHttpBinding_DataService" />
</client>
</system.serviceModel>
</configuration>
The code above can be used to change the address (e.g. https://localhost:44300/Services/DataService.svc) to one generated at runtime...
And have a look at this: http://blog.rsuter.com/?p=281
I have an ASP.NET web project and a membership provider configured via my web.config. Its fully working so no problem there.
We have an older system with a lot of users and I would therefor like to create a class library that can create users in this ASP.NET project but since its a class library it cannot have its own app.config-file.
is it possible to set all this information via code somehow?
<membership defaultProvider="ShidMembershipProvider">
<providers>
<clear/>
<add name="ShidMembershipProvider" type="SundaHus.AspNet.Membership.ShidMembershipProvider" connectionStringName="ShidConnectionString" enablePasswordRetrieval="true" enablePasswordReset="true" requiersQuestionAndAnswer="true" applicationName="ECB3-development" minRequiredPasswordLength="5"/>
</providers>
</membership>
You have a custom membership provider it looks like? This connects to your own custom database? You should be able to just point to that database for your code. Or, if you just inherit the functionality from the base class, you can also try overriding the Initialize method, look for the connection string, and change the value to something else.