MSMQ + WCF, IIS7 - Messages are being journaled, but never hitting the service - wcf

Standard set up I think. I've followed: http://blogs.msdn.com/b/tomholl/archive/2008/07/12/msmq-wcf-and-iis-getting-them-to-play-nice-part-1.aspx mainly, but used other sources as needed.
So far here is what happens:
Client sends a message
I see the message in the Journal Messages for the appropriate queue
Service never seems to be called. I have a ton of logging that would output logs on service called and / or errors in the service method.
I have shut down the service and the message still ends up in the Journal Messages - not sure why that is.
Queue: bretrace/bretraceservice.svc (anonymous access, with full permissions granted)
Client Web.config
<netMsmqBinding>
<binding name="MsmqBreTrace" receiveErrorHandling="Move">
<security mode="None" />
</binding>
</netMsmqBinding>
<endpoint address="net.msmq://wcfserver/private/bretrace/bretraceservice.svc" binding="netMsmqBinding"
bindingConfiguration="MsmqBreTrace" name="MsmqBreTraceService"
contract="C.BusinessRuleController.Services.BoschProxy.Trace.IQueuingTraceContract"/>
Service Web.config
<bindings>
<netMsmqBinding>
<binding name="MsmqBreTraceReader" receiveErrorHandling="Move">
<security mode="None" />
</binding>
</netMsmqBinding>
</bindings>
<services>
<service name="C.BusinessRuleController.Services.QR.BreTraceService">
<endpoint address=""
binding="netMsmqBinding" bindingConfiguration="MsmqBreTraceReader"
contract="C.BusinessRuleController.Services.BoschProxy.Trace.IQueuingTraceContract" />
</service>
</services>
I have also activated system.diagnostics, and it seems to be calling the service, under activity I see:
"Process Action: 'http://tempuri.org/IQueuingTraceContract/LogTrace'." I'm not sure if the tempuri.org is a problem or not?
"Execute C.BusinessRuleController..." as another activity.

Couple of things solved this problem for me:
First, I had to set security mode='transactional' in the bindings
<netMsmqBinding>
<binding name="MsmqBreTrace" receiveErrorHandling="Move">
<security mode="Transactional" />
</binding>
</netMsmqBinding>
Second, I had to installed MSMQ Active Directory Integration - I didn't have to actually enable it, but it had to be installed even when it wasn't used. This was what threw me the most, I didn't want AD Integration, so I figured I didn't need it. Turns out I was wrong.

Related

MSMQ WCF hosted in IIS

I am stuck in the following case - I have two web applications – A and B. They are both running on the same computer. B is hosting a netMsmqBinding WCF Service. Also, B’s application pool has just recycled itself. A calls B’s WCF service. I see that the message has arrived in the private MSMQ queue which I have created. But until I don’t browse the *.svc URL the message is not proceed by B.
Am I missing something required by this technology? What is the clean way to implement such a functionality?
These are the configuration that I am using. If I missed some helpful info, please, tell me and I will provide it:
The service (B):
<system.serviceModel>
<services>
<service name="MyProject.Web.Services.EmsListener">
<endpoint address="net.msmq://localhost/private/myQueue"
binding="netMsmqBinding" bindingConfiguration="MyMsmqBinding"
contract="MyProject.Abstraction.IEmsListener">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<netMsmqBinding >
<binding name="MyMsmqBinding"
durable="true"
receiveRetryCount="2"
maxRetryCycles="2"
retryCycleDelay="00:01:00"
receiveErrorHandling="Move" >
<security mode="None">
<message clientCredentialType="None"/>
<transport msmqAuthenticationMode="None" msmqProtectionLevel="None" />
</security>
</binding>
</netMsmqBinding>
The client(A):
<system.serviceModel>
<bindings>
<netMsmqBinding>
<binding name="MyBinding ">
<security mode="None" />
</binding>
</netMsmqBinding>
</bindings>
<client>
<endpoint address="net.msmq://localhost/private/myQueue" binding="netMsmqBinding"
bindingConfiguration=" MyBinding " contract="EmsListener.IEmsListener"
name=" MyBinding " />
</client>
</system.serviceModel>
Thanks in advance :)
This may be because IIS is not starting your application after recycled.
Possible solution is to configure auto-start. Then IIS will start your service immediately without waiting for the first request.
The possible solution of Imortist works!!
But first you need to add AppFabric to your ISS, then you need be sure you have the "Start Mode" option in your pool advance settings.
Note: In my windows 7 IIS7 didnt work, but in my windows server 2012 R2 IIS8 Works perfectly

Error: The HTTP request is unauthorized with client authentication scheme 'Negotiate'

I keep getting the above error when my client program tries to call my WCF service method. It is passing credentials via ClientCredential.UserName.
I am not able to figure out what's happening here and all the posts related to this kind of issue are not solving this problem.
Mine is a shared hosting Environment on Godaddy server where my WCF service is hosted.
Configuration is as follows:
<endpoint
name="wsBinding"
address=""
binding="wsHttpBinding"
contract="ServiceLib.IBooking"
bindingConfiguration="myWSSettings"/>
<bindings>
<wsHttpBinding>
<binding name="myWSSettings">
<security mode="Transport">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
Would really appreciate any help.
Thanks
Sandeep

Can't Activate WCF service

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.

Why doesn't my WCF endpoint throw a Max Clock Skew exception?

With almost all of the (secure) WCF service endpoints in my application, if the client's system clock is set too far in the future or past, I get an exception from WCFs Clock Skew mechanism (described here: http://www.danrigsby.com/blog/index.php/2008/08/26/changing-the-default-clock-skew-in-wcf/).
However the one endpoint where my Login() method is implemented never throws this exception even though it has transport security enabled (naturally no credentials are required for it).
Why isn't the "Clock Skew mechanism" working for this endpoint? Maybe it's because clientCredentialType is set to "None"?
As an example, here's a simplified version of my configuration:
<services>
<service name="Foo">
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="binding1"
contract="IFoo" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="binding1" maxReceivedMessageSize="100000000">
<readerQuotas maxDepth="1000000000" maxArrayLength="1000000000" maxStringContentLength="1000000000" />
<security mode="Transport">
<transport clientCredentialType ="None"/>
</security>
<reliableSession enabled="false" />
</binding>
</wsHttpBinding>
</bindings>
The security mode - security mode="Transport" - does not include time stamp in the message which cause the MaxClockSkew validation to ignore the message and not throws a security exception.
Change the security mode to security mode="TransportWithMessageCredential" which include time stamps and allow the MaxClockSkew validation to test the message for time delta.
Other people have a similar problem:
Triggering MaxClockSkew when accessing WCF service
So I do not think that it is a problem with your configuration.
It appears to be, that if it does not use machine time, it does not check if there is a difference in time between the machines.
You could program your way around it, send the client machine time as a parameter in your login method, if it is different, throw an exception.

WCF Error: Stream Security is required at http://www.w3.org/2005/08/addressing/anonymous, but no security context was negotiated

We have a windows service that we are trying to use as WCF host for a WPF application. It works fine in development but when we have tried to move to our production environment we have had nothing but problems. From reading posts from others, we figured out how to turn on WCF logging and this was a big help. It turned out that our security bindings on the service and the client did not match. We set them both to use windows security but still no luck now we are trying to set the security mode to 'None' but it still is not working. Here is the bindings section of our service config file:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="netTcp">
<security mode='None'>
</security>
</binding>
</netTcpBinding >
</bindings>
<services>
<service name="CompanyService">
<endpoint
address= "our.url.com/CompanyService"
binding="netTcpBinding"
contract="CompanyServices.ICompanyService" />
</service>
</services>
</system.serviceModel>
Here is the serviceModel section of our client app config:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_Config" >
<security mode="None">
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="our.url.com/CompanyService" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_Config" contract="CompanyServiceProxy.ICompanyService" name="NetTcpBinding_ICompanyService" />
</client>
</system.serviceModel>
If I need to supply additional infor please tell me what I need to supply.
Thanks
Standard net.tcp binding uses Windows credentials by default, and those really require client and service to be in the same Windows domain. Is this the case here??
OK, sorry, you mentioned security=None (your listings weren't properly formatted so I only saw a fraction of the actual config).
I guess your problem really lies in the addresses used:
address= "our.url.com/CompanyService"
When using net.tcp binding, you have to specify that before the address, so change this on both the client and the server to:
address= "net.tcp://our.url.com/CompanyService"
Also, what I don't quite understand is your title: it mentions "streaming" - have you specified streaming mode anywhere? In your config or your service contracts?
Marc