I have WCF service. Here is configuration
<basicHttpBinding>
<binding name="EmergencyRegistratorBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
And service configuration
<service behaviorConfiguration="Default" name="Breeze.AppServer.Emergencies.EmergencyRegistrator">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="EmergencyRegistratorBinding"
contract="Services.IEmergencyRegistrator" />
</service>
Everything worked fine. But I needed to change basicHttpBingind to DuplexBinding.
I have added extention:
<extensions>
<bindingElementExtensions>
<add name="pollingDuplex" type="System.ServiceModel.Configuration.PollingDuplexElement, System.ServiceModel.PollingDuplex"/>
</bindingElementExtensions>
</extensions>
And changed mentioned above lines to:
<customBinding>
<binding name="DuplexmergencyRegistratorBinding">
<binaryMessageEncoding/>
<pollingDuplex maxPendingSessions="2147483647" maxPendingMessagesPerSession="2147483647" inactivityTimeout="02:00:00" serverPollTimeout="00:05:00"/>
<httpTransport authenticationScheme="Negotiate"/>
</binding>
</customBinding>
and
<service behaviorConfiguration="Default" name="Breeze.AppServer.Emergencies.EmergencyRegistrator">
<endpoint address="" binding="customBinding" bindingConfiguration="DuplexmergencyRegistratorBinding" contract="Breeze.Core.Services.IEmergencyRegistrator" />
<endpoint address="mex" binding="customBinding" bindingConfiguration="DuplexmergencyRegistratorBinding" contract="IMetadataExchange"/>
</service>
I have added Service Reference to WCF project. Reference was successfully added but Reference.cs was almost empty.
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.225
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
When I uncheck option "Reuse types in referenced assemblies"
Code is generated but there above 10 thousands lines instead of ~500
I run svcutil and I've got next:
svcutil.exe http://localhost/Breeze.Workstation/Emergencies/EmergencyRegistrator.svc?wsdl
Attempting to download metadata from 'http://localhost/Breeze.Workstation/Emergencies/EmergencyRegistrator.svc?wsdl' using WS-Metadata Exchange or DISCO.
Warning: The following Policy Assertions were not Imported:
XPath://wsdl:definitions[#targetNamespace='http://tempuri.org/']/wsdl:binding[#name='CustomBinding_IEmergencyRegistrator']
Assertions: ..
Generating files...
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\EmergencyRegistrator.cs
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\output.config
I'm quite new to WCF services. I hope somebody will be able to help me.
Thanks.
I've solved that.
Empty reference was due to some problems with ambiguous types. When I fixed it, reference.cs file generated well.
So, solution is to look not only at errors, but at warnings too. I have found there all information what I need for my problem. Happy codding
The polling duplex HTTP binding is only supported by Silverlight clients. Since you're using svcutil to generate the reference, I assume you're building a "normal" (i.e., non-SL) client for the server, so that won't work.
If you want to use a duplex binding on a non-Silverlight application, you can take a look at either the wsDualHttpBinding or netTcpBinding.
Related
Apologies for the long post but I want to include as much information as possible. So I've been struggling for days now to get my WCF service to work correctly with my silverlight app. I had originally deployed it and everything was running smoothly.
However After i made an update to one of the methods it has not worked since. I use SVN to store my work and even going back to previous versions of the project and redploying it has not helped. Please can someone assist me :(
If I run my silverlight application through VS2012 it works correctly all calls to the service work as required and retrieve the correct information. However if i trigger the same calls once the silverlight app is deployed I receive 1 of the following errors:
An exception occurred during the operation, making the result invalid. Check InnerException for exception details.
at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at OrionDashboard.OrionWebService.GetTestDataCompletedEventArgs.get_Result()
at OrionDashboard.MonthlyOverview.OrionWebService_GetTestDataCompleted(Object sender, GetTestDataCompletedEventArgs e)
at OrionDashboard.OrionWebService.OrionWebServiceClient.OnGetTestDataCompleted(Object state)
Or
[Async_ExceptionOccurred] Arguments: Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=4.0.51204.0&File=System.dll&Key=Async_ExceptionOccurred at
With the rest of the error corresponding to the onComplete event error of the other error message.
Again this only happens when its deployed to the IIS on the server, And it only started happening after i made the update an redeployed
I've used both WCF Storm and WCF Test Client that was included with VS2012 to test the deployed service over the network and everything is being returned without any issues for all the contracts.
Here is the ServiceReferences.ClinetConfig:
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CustomBinding_OrionWebService">
<binaryMessageEncoding />
<httpTransport maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost:53493/OrionWebService.svc"
binding="customBinding"
bindingConfiguration="CustomBinding_OrionWebService"
contract="OrionWebService.OrionWebService"
name="CustomBinding_OrionWebService" />
</client>
</system.serviceModel>
I have made no changes to this at all from what was auto generated when i referenced the service project. I thought it may have been this line: "http://localhost:53493/OrionWebService.svc"
because in fiddler i receive the following errors on the crossdomain.xml and the clientaccesspolicy.xml
[Fiddler] The socket connection to localhost failed.
ErrorCode: 10061.
No connection could be made because the target machine actively refused it [::1]:53493
however when i changed the xap to a zip file and modified the ServiceReference.ClientConfig to point to the same service address as would work if you wanted to check your service e.g. "http://ServerName/OrionDashboard/OrionWebService.svc" I still get the same error from silverlight and then get a 404 error from the two files.
Here is the web.config:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true"
targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="OrionDashboard.Web.OrionWebService.customBinding0">
<binaryMessageEncoding />
<httpTransport />
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<services>
<service name="OrionDashboard.Web.OrionWebService">
<endpoint address=""
binding="customBinding"
bindingConfiguration="OrionDashboard.Web.OrionWebService.customBinding0"
contract="OrionDashboard.Web.OrionWebService" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
</configuration>
As with the ServiceReference, the web.config too was left alone because I dont really understand what most of it means. But I left it as is when I first deployed the silverlight app and as mentioned it worked fine then.
I don't believe its a DB issue since it runs locally without any issues and the service responds with the correct data from the deployed service as well.
The service seems to be working fine, no issues reported from either the WCF Test Client or WCF Storm app
In VS2012 when publishing the wcf service it doesn't separate the service from the client and it doesn't create the crossdomain.xml or clientaccesspolicy.xml so I manually added those after publishing it. Not sure if that could possibly be the cause?
I'm completely lost and every work around I've found so far has not worked for me. Please can someone at least point me in the right direction?
I'm working over WCF and it worked fine on localhost. After I placed it on the production server, it thows an exception
The requested service, 'http://global-kazway.kz/Service1.svc' could
not be activated. See the server's diagnostic trace logs for more
information
I'm new in Services and have been trying to solve this problem for almost 3 hours.
Here is the App.config of the client;
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections></configSections>
<connectionStrings>
<add name="TestProject.Properties.Settings.DBConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\1\Documents\visual studio 2010\Projects\TestProject\TestProject\AppData\DB.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" /><add name="DBEntities" connectionString="metadata=res://*/DBModel.csdl|res://*/DBModel.ssdl|res://*/DBModel.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;attachdbfilename=C:\Users\1\Documents\visual studio 2010\Projects\TestProject\TestProject\AppData\DB.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" /><add name="DBEntities1" connectionString="metadata=res://*/DBModel.csdl|res://*/DBModel.ssdl|res://*/DBModel.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\AppData\DB.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" /></connectionStrings>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://global-kazway.kz/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="kazwayServiceReference.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
First step in troubleshooting a WCF application is to bring up a browser and type in the service URI. So based on the client: you'd navigate to http://global-kazway.kz/Service1.svc
Now see what kind of results you get. Exception? The service screen? Usually you can get your best information from this screen! Sometimes it points out what your issue is such as missing a behavior.
Compare your web.config with the deployed web.config entries. You may find something there as well. Finally you may just have to manage security on your folder. But the browser display could spell everything out for you very clearly.
I'm working on a project and I faced the same problem.
When I checked the Event Viewer to trace the error, I found where the problem was.
Event Viewer message:
Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/7540993
Exception: System.ServiceModel.ServiceActivationException: The service '/CODWebService/Service1.svc' cannot be activated due to an exception during compilation. The exception message is: Memory gates checking failed because the free memory (164065280 bytes) is less than 5% of total memory. As a result, the service will not be available for incoming requests. To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.. ---> System.InsufficientMemoryException: Memory gates checking failed because the free memory (164065280 bytes) is less than 5% of total memory. As a result, the service will not be available for incoming requests. To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.
Then I added the below code to my service's web.config file.
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="1" />
This element should be placed in <system.serviceModel>
i'm working over WCF and it worked fine on localhost.After i placed it to the production server, it thows me an exception "The requested service, 'http://global-kazway.kz/Service1.svc' could not be activated. See the server's diagnostic trace logs for more information"
This MSDN article describes how to configure tracing on the server. Once you've done that you can look at the server's diagnostic trace logs, and will likely find the problem.
To have a more detailed description of the error please insert this code in your web.config file of the service:-
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
Then use this service behavior in your service like this :-
<service name="MyService" behaviorConfiguration="MyServiceBehavior" >
<endpoint address="" binding="basicHttpBinding" xxxx="" xxxxx="" xxxxx="" xxxx="" xxxx="" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
<host>
<baseAddresses>
<add baseAddress="http://ServerAddress:AnyPortIfspecified/VirtualDirname"/>
</baseAddresses>
</host>
</service>
This will give you a detailed description of the error.
The second thing that you may try is check this:-
<host>
<baseAddresses>
<add baseAddress="http://ServerAddress:AnyPortIf specified/VirtualDir name"/>
</baseAddresses>
</host>
make sure your base address is not localhost.
TC
I was able to resolve the issue by following below steps using Visual Studio 2013:
Go to your project folder where you have your *.svc file
Right Click *.svc file --> View in browser
Validate if you are able to browse the service
Go to your project folder where you have your app.config file or where you want to consume the service.
Right click project-->Add-->Service Reference
Click Discover-->Under Services Select Service-->Give desired name to your service reference-->Click OK
It will create "ServiceReference1" under the folder "Service References" & automatically create/update app.config file
First thing take the service url address(e.g. http://youservice:808/Area.Service/Service.svc) and put it into browser url field to check whether the service is running.
In my case it wasn't running.
The remote server had a process running that used a lot or CPU and RAM (sql process)
This was blocking the service.
By closing/stopping some processes in Task Manager on remote server recovered the service.
In addition to the accepted answer, I visited the exact URL where the Service.svc mapped in URL.
From there you can see the detailed issue, on my case this is the error:
Looking at the issue, I have the correct configuration on my web.config file, but I noticed that it is looking for the assembly, from there, I figured out that I haven't reference the Service Contract project including Service Implementation and Data Access Layer assembly.
I'm trying to get started with transactions in WCF, using the free Microsoft Visual Web Developer 2010 Express. It gives me the option to create a "WCF Service Application" but it doesn't appear to give me many options for hosting it or configuring different bindings. If I F5 the project I get the error:
At least one operation on the 'Service' contract is configured with the TransactionFlowAttribute attribute set to Mandatory but the channel's binding 'BasicHttpBinding' is not configured with a TransactionFlowBindingElement. The TransactionFlowAttribute attribute set to Mandatory cannot be used without a TransactionFlowBindingElement.
I've tried adding in */services/service/endpoint configuration into the web.config but it appears to just be ignored. I also tried to change the default startup application to WcfSvcHost.exe but this option is greyed out. I'm beginning to suspect the Express edition of some failings but am optimistic that it's just me being a dunce. Is there a trick I need to learn, or will splashing out on the full version of Visual Studio 2010 be enough to get me over this hurdle and onto the next one?
Thanks!
Without knowing your configuration and service contract it is almost impossible to make targeted answer. If you think that your configuration is ignored make sure that names used in service and endpoint/#contract contains CLR namespaces.
WCF 4 uses nice simplified configuration which IMHO made real configuration much bigger pain then it was before. You can switch defaults by adding this to your web config:
<protocolMapping>
<remove scheme="http" />
<add scheme="http" binding="wsHttpBinding" bindingConfiguration="transactionFlowEnabled"/>
</protocolMapping>
<bindings>
<wsHttpBinding>
<binding name="transactionFlowEnabled" transactionFlow="true" />
</wsHttpBinding>
</bindings>
This is workaround which should use defined binding as default instead of basicHttpBinding.
Thanks to Ladislav's suggestion, I was able to solve this by adding the following entries into the Web.config file:
<services>
<service name="WcfService1.Service1">
<endpoint
address=""
binding="wsHttpBinding"
contract="WcfService1.IService1"
/>
</service>
</services>
and:
<bindings>
<wsHttpBinding>
<binding transactionFlow="true"/>
</wsHttpBinding>
</bindings>
I have a RESTful service which I'm trying to enable to accept a PDF file. I'm using a stream to transport it, but I keep running into mysterious errors in the process.
My first error is this: Security negotiation failed because the remote party did not send back a reply in a timely manner. This may be because the underlying transport connection was aborted.
Not sure what's causing that. Also, I tried adding a customBinding in an attempt to fix this error, and I get an error that says I don't have my binding set up properly.
My main, overall question is this:
Does anyone know of a simple binding and complete instructions for how to set it up to enable streaming?
I managed to get it working. I found that my problem wasn't my binding, but that it was never registered. Here's the code in the web.config file:
<services>
<service name="ResearchUploadService.Service1" behaviorConfiguration="ResearchUploadService.Service1Behavior">
<endpoint address="" binding="customBinding" bindingConfiguration="basicConfig" contract="ResearchUploadService.IService1"/>
</service>
</services>
...
<bindings>
<customBinding>
<binding name="basicConfig">
<binaryMessageEncoding/>
<httpTransport transferMode="Streamed" maxReceivedMessageSize="67108864"/>
</binding>
</customBinding>
</bindings>
When using a WSHttpBinding in WCF with reliableSessions enabled, my service reference updates itself to:
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="true">
</reliableSession>
I cannot add the maxRetryCount attribute to the reliableSession as long as the binding is configured as a WSHttpBinding.
Now my question: what is the value of maxRetryCount when using a WSHttpBinding, and is there any way to change this in config; without the use of a CustomBinding?
You cannot set the maxRetryCount on a standard wsHttpBinding configuration. In order to set that value, you need to create a separate custom binding and then reference that from your service or client config:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="wsCustomBinding">
<reliableSession maxRetryCount="15"/>
<textMessageEncoding/>
<httpTransport />
</binding>
</customBinding>
</bindings>
<services>
<service name="MyService">
<endpoint address="http://localhost:7878/MyServoce"
binding="customBinding"
bindingConfiguration="wsCustomBinding"
contract="IMyService" />
</service>
</services>
</system.serviceModel>
Defining a custom binding isn't hard - but you need to make sure you specify the elements that make up the binding in the right order - see the MSDN docs on custom bindings for a reference.
If you want to share the custom binding configuration between server and client, you could also put that <bindings> section into a separate bindings.config file, and then reference that external file from your web.config/app.config:
<system.serviceModel>
<bindings configSource="bindings.config">
Visual Studio will complain about this and show red squiggly underlines - but trust me - the technique works, I use it in production every day (the Visual Studio XML schema describing the config stuff isn't complete and accurate).
Marc