I am trying to test time out configuration in WCF Service. I want the service to timeout a request based on the settings in config or code. WCF client (i.e. example a web application) with similar configuration timeouts as expected, but I want the service itself to honor the setting and timeout.
Tested this in couple of ways.
1.) IIS hosted WCF service with timeout listed in web.config
<bindings>
<basicHttpBinding>
<binding name="Service1Binding" closeTimeout="00:00:10" openTimeout="00:00:10" receiveTimeout="00:00:10" sendTimeout="00:00:10">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="Service1">
<endpoint address="Service1" binding="basicHttpBinding" bindingConfiguration="Service1Binding" name="IService1" contract="TestWcfTimeout.IService1" />
</service>
</services>
2.) Self hosted WCF service with timeout listed in code
using (var host = new ServiceHost(typeof(Service1), baseAddress))
{
var smb = new ServiceMetadataBehavior{ HttpGetEnabled = true, MetadataExporter = { PolicyVersion = PolicyVersion.Policy15 }};
var endpoint = host.AddServiceEndpoint(typeof(IService1), new BasicHttpBinding(), baseAddress);
endpoint.Binding.OpenTimeout = new TimeSpan(00, 00, 00, 10);
endpoint.Binding.CloseTimeout = new TimeSpan(00, 00, 00, 10);
endpoint.Binding.SendTimeout = new TimeSpan(00, 00, 00, 10);
endpoint.Binding.ReceiveTimeout = new TimeSpan(00, 00, 00, 10);
host.Description.Behaviors.Add(smb);
host.Open();
Console.WriteLine("The service is ready at {0}", baseAddress);
Console.WriteLine("Press <Enter> to stop the service.");
Console.ReadLine();
host.Close();
}
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(int value);
}
Tested this using SoapUI client. Made sure the method GetData takes more time to complete execution than the configured time out. So the service can timeout the request.
--> But the service does not honor the timeout and client receives wcf response object even after reaching the timeout setting. Any idea?
Noticed similar behavior on a web application, where the service does not timeout even after reaching configuration time.
--> Any feedback is appreciated
Your web.config timeouts refer to the client's operations. What you were doing was setting your web service's attitude toward your client.
Based on your configuration, this means that if your client takes more than 10 seconds between e.g. two requests to your web service, your client will get a timeout exception because your web service will say "Hey! You exceeded the timeout in my web.config. You are late and I won't answer!".
Set the same timeouts in your client's config and repeat your experiment, delaying GetData's response: then your client will throw an exception and discard your web service's response.
Now, if you are looking for a way to set a timeout service-side, so that your service stops processing a request if it exceeds a time limit... you will have to implement it yourself.
Related
I hosted webservice in private server. I then created URL rewrite rule in IIS which is there in public server(internet server).
Everytime I access the URL, It explicitly shows the private server's ip/ computer name in URL on browser rather than public url/IP. When I click on the URL for viewing script, it shows "Example.svc does not exist" error.
It also doesn't work when i try to add it as service reference in Visual studio by passing the URL in it. It throws the below error.
The request failed with HTTP status 400: Bad request
Metadata contains a reference that cannot be resolved: <SERVER URL>
The remote server turned an unexpected response: (405) Method not allowed.
What should I do for accessing the URL publicly and also able to add it as reference in Visual studio.?
It seems that you are deploying a WCF service in IIS. Is that correct? If the error “example.svc does not exists” occurred, please ensure that you have enabled certain Windows features in order to host WCF service in IIS.
The reason why we cannot add it as Service Reference in order to call the service is that we have not published the Metadata service endpoint. This depends on your WCF service type. Generally, we either add a Mex service endpoint or publish the service WSDL by adding Metadata service behavior.
<services>
<service name="WcfService1.Service1">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="mybinding" contract="WcfService1.IService1">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
Everytime I access the URL, It explicitly shows the private server's ip/ computer name in URL on browser rather than public url/IP.
In order to access the service by using the hostname/domain name URL, we should ensure that the domain name points to the public IP of the server. It is a network-related issue.
Feel free to let me know if the problem still exists.
We are calling web service for which using cxf-codegen-plugin for code generation from WSDL and have configured JAX-WS client in Spring xml as follows:
<jaxws:client id="abcApiInterface" serviceClass="abc.api.AbcApi" address="${xyz.abcApi.endpoint}" />
And we have our webservice interface generated by Apache CXF 3.0.3. We are seeing timed-out when calling that service, we have not specified any timeout on client side so just want to know what's the default value for timeout for JAX-WS client?
Default value is 30 seconds for connection timeout and 60 seconds for receive timeout.
See: http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport(includingSSLsupport)-Theclientelement
I have a pair of Win 2012 servers running as a web-server and WCF-server and I want to increase the number of outgoing connections from the web-server to the WCF-server (which appears to be limited to 24)
Windows 2012 R2
2 CPUs (each server)
IIS 8.5 (Integrated App Pools)
ASP.NET 3.5 WebForms App
wsHttpBinding
WCF v3.5 Service
I have proved that the WCF server can handle more than 24 concurrent connections (by loading the WCF WSDL with JMeter and 800 threads) - so this is pointing me to believe that the ASP.NET outgoing connections are being throttled.
I have already tried;
adding maxconnections (into both web and WS web.config files)
changing machine.config processModel and httpRuntime value (from here)
For example:
<connectionManagement>
<add address="*" maxconnection="96"/>
</connectionManagement>
and
<processModel maxWorkerThreads="100" maxIoThreads="100" minWorkerThreads="50" />
<httpRuntime minFreeThreads="176" minLocalRequestFreeThreads="152" />
Within the web service I have already tried the service model behaviour settings too (2 CPU's);
<serviceThrottling maxConcurrentCalls="32" maxConcurrentSessions="200" maxConcurrentInstances="232"/>
I have a client application which talks to our Web Service hosted on a server (we'll call it hostServer). My client application can build and connect fine using basicHttpBinding. However, I'm trying to impliment wsHttpBinding for security reasons.
Last week before lunch I could swear it was working with a hardcoded certificate. Came back from lunch, checked in my code and now it won't run. I keep getting "There was no endpoint listening at https://hostServer:1234/Service.svc/MyServiceName that could accept the message. This is often caused by an incorrect address or SOAP action.". I've tried re-checking my settings, retracing my steps, but can't seem to get back to the functioning state I was in.
I am using a ServiceReference with an address of "https ://hostServer:1234/Service.svc?singleWsdl". I can navigate to "https ://hostServer:1234/Service.svc" without a problem and view the Wsdl.
My client code is
WSHttpBinding wsBinding = new WSHttpBinding(SecurityMode.Transport);
wsBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
Client = new MyServiceName(wsBinding, new EndpointAddress(endpoint));
Client.ClientCredentials.ClientCertificate.SetCertificate(
StoreLocation.CurrentUser,
StoreName.My,
X509FindType.FindBySubjectName,
"localCertName");
Client.ChangePassword("test_user", "pt", "a1");
My value endpoint = https://hostServer:1234/Service.svc/MyServiceName
My IIS site is set up with Binding for Http and Https (with correct IP & Port ID)
I really need to get this code working before taking off (my wife is due with our second child any day). I've been working to debug this now for 2 days, in addition to the time it took me to stand it up as is. Please help.
So I was finally able to get this working again. Listing what steps were performed below in hopes that it might help someone else.
On IIS Server (IIS Manager):
Modified "Site Bindings" to include HTTP & HTTPS (w/different Port Numbers)
Set SSL setting to "Require SSL" and "Accept"
On IIS Server (Web.Config):
Added
<bindings>
<wsHttpBinding>
<binding name="wsHttpEndpointBinding">
<security mode="Transport">
<transport clientCredentialType ="Certificate"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
to the "System.ServiceModel" tag.
Also, added 'bindingConfiguration="wsHttpEndpointBinding"' to my endpoint.
In Code
Updated Endpoint address to use that generated on the IIS Server.
Used the following code for creating the endpoint
WSHttpBinding wsBinding = new WSHttpBinding(SecurityMode.Transport);
wsBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
Client = new ServiceClient(wsBinding, new EndpointAddress(endpoint));
Client.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindByIssuerName, certName);
Error Message:
[EndpointNotFoundException: There was no endpoint listening at "Link/MobileMotivation.asmx" that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.]
This is a MVC4 applcation, it works fine on the local machine. However when I implement it to the server which is the same server as the web service, it shows the error message.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MobileMotivationSoap" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://stuiis.cms.gre.ac.uk/bb116/FinalYear2/FinalYear2/MobileMotivation.asmx"
binding="basicHttpBinding" bindingConfiguration="MobileMotivationSoap"
contract="MobileMotivationService.MobileMotivationSoap" name="MobileMotivationSoap" />
</client>
You might need to edit the anonymous authentication settings.
Go to:
Server Manager
IIS
Connections > Sites > YourSite
Click Authentication > Enable
At this point you can select application pool identity.
More details here: A web site code can't connect to a soap service on the same server