I have a program with three WCF services and when I run them locally (i.e: Server and Clients are all on localhost) everything works. However when I test them across a network I get a TimoutException on two services but not the other. I've disabled the firewalls on all the machines involved in the test. I can both ping the server and access the wsdl "You have created a service" webpage from the client
The service that works uses a BasicHttpBinding with streaming and the two which don't work use WSDualHttpBinding. The Services that use WSDualHttpBinding both have CallbackContracts. I apologise for the vagueness of this question but I'm not really sure what code to include or where to even start looking for the solution to this.
Non-working bindings:
public static Binding CreateHTTPBinding()
{
var binding = new WSDualHttpBinding();
binding.MessageEncoding = WSMessageEncoding.Mtom;
binding.MaxBufferPoolSize = 2147483647;
binding.MaxReceivedMessageSize = 2147483647;
binding.Security.Mode = WSDualHttpSecurityMode.None;
return binding;
}
Exception Stack Trace:
Unhandled Exception: System.TimeoutException: The open operation did not complete within the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout.
Server stack trace:
at System.ServiceModel.Channels.ReliableRequestor.ThrowTimeoutException()
at System.ServiceModel.Channels.ReliableRequestor.Request(TimeSpan timeout)
at System.ServiceModel.Channels.ClientReliableSession.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ClientReliableDuplexSessionChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at IDemeService.Register()
at DemeServiceClient.Register()
at DemeClient.Client.Start()
at DemeClient.Program.Main(String[] args)
You may enable System.Net tracing on both sides and read about the Timeout exception.
http://support.microsoft.com/kb/947285
You are using a DualHttpBinding. What this means is that you are setting up a duplex channel, where server can send messages (not response message, but a incoming message) to client. But you haven't setup a clientBaseAddress where client will be listening for incoming messages from server. This is what is causing this issue. from http://msdn.microsoft.com/en-us/library/system.servicemodel.wsdualhttpbinding.aspx:
This binding requires that the client has a public URI that provides a callback endpoint for the service. This is provided by the ClientBaseAddress. A dual binding exposes the IP address of the client to the service. The client should use security to ensure that it only connects to services it trusts.
Related
Starting at about 11 PM CST on 5/29/2017, I began receiving "(400) Bad Request" errors for all my ItemSearch() calls. I am using the C# API and have been doing so successfully for well over a year now with no problems. No code or configuration has changed on my end, and I have been able to reproduce the error both in production and development. My security credentials appear to still be valid according to the IAM Management Console, and I haven't received any communications from Amazon that would indicate that my account has been deactivated or anything of that nature.
This is what is returned for all of my calls:
System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at MyCode.com.amazonaws.ecs.AWSECommerceServicePortType.ItemSearch(ItemSearchRequest1 request)
Is anyone else experiencing this?
I did check this very old thread, but I don't believe it's relevant given how this sprung up out of nowhere and has been working perfectly for so long.
A normal HTTP WCF Service is throwing this error when trying to connect to a legacy NetTCP binding. I want to be able to flow the transaction to the service and have that enabled. I am not using a duplex contract so why is it even mentioning a 'callback' contract in the error message?
Please just say if you need to see some more code, but I'll take any suggestions right now!
** the error is thrown when it's doing a ChannelFactory.CreateChannel()
The operation 'XService' on callback contract 'IXService' is configured with TransactionAutoComplete set to false. TransactionAutoComplete set to false cannot be used with operations on callback contracts.
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at IXService.Add(Int32 id, Int32 createdById, String note, Int32 productTypeId, Int32 noteTypeId)
at XService.Add(Int32 id, Int32 createdById, String note, Int32 productTypeId, Int32 noteTypeId)
I had the same problem.
I was starting a service programmaticaly all along with the configuration (base address, binding, endpoint,...).
I ended up exporting all configuration to the config file and it worked.
I am trying to integrate with a Java service from WCF. The server requires an OASIS WSSE security header for username + password authentication. Transport security is provided by SSL on the server side (no client certificate for mutual authentication). The request is working, but WCF falls over when processing the response...
Using Fiddler2, I see a valid response coming back from the server without any issues, but it looks like WCF chokes on the wsse:UsernameToken which is echoed in the response from the server.
Is there any way to ignore client-side authentication on the token coming back in the server's response? I imagine I need to have a dummy authenticator and somehow attach it to the client's response processing, but I am not sure where to hook into that logic.
I do not want to use WSE 3.0 and all the client setup is in code (no external assemblies or config files).
Code
private static IEndPointClient NewProxy(string userName, string password)
{
//Basic SOAP over TLS/SSL with WSSE header for authentication
var baseBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
//Strip the TimeStamp element from the WSSE header - server does not expect it
var elements = baseBinding.CreateBindingElements();
var securityElem = elements.Find<SecurityBindingElement>();
securityElem.IncludeTimestamp = false;
var binding = new CustomBinding(elements);
var address = new EndpointAddress(UATSERVER);
var svc = new EndPointClient(binding, address);
svc.ClientCredentials.UserName.UserName = userName;
svc.ClientCredentials.UserName.Password = password;
}
MessageSecurityException message and stack trace
Cannot find a token authenticator for the 'System.IdentityModel.Tokens.UserNameSecurityToken' token type. Tokens of that type cannot be accepted according to current security settings.
Server stack trace:
at System.ServiceModel.Security.ReceiveSecurityHeader.ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver, IList`1 allowedTokenAuthenticators, SecurityTokenAuthenticator& usedTokenAuthenticator)
at System.ServiceModel.Security.ReceiveSecurityHeader.ReadToken(XmlDictionaryReader reader, Int32 position, Byte[] decryptedBuffer, SecurityToken encryptionToken, String idInEncryptedForm, TimeSpan timeout)
at System.ServiceModel.Security.ReceiveSecurityHeader.ExecuteFullPass(XmlDictionaryReader reader)
at System.ServiceModel.Security.StrictModeSecurityHeaderElementInferenceEngine.ExecuteProcessingPasses(ReceiveSecurityHeader securityHeader, XmlDictionaryReader reader)
at System.ServiceModel.Security.ReceiveSecurityHeader.Process(TimeSpan timeout, ChannelBinding channelBinding, ExtendedProtectionPolicy extendedProtectionPolicy)
at System.ServiceModel.Security.TransportSecurityProtocol.VerifyIncomingMessageCore(Message& message, TimeSpan timeout)
at System.ServiceModel.Security.TransportSecurityProtocol.VerifyIncomingMessage(Message& message, TimeSpan timeout)
at System.ServiceModel.Security.SecurityProtocol.VerifyIncomingMessage(Message& message, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates)
at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout)
at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
You have two options:
Implement a custom message encoder in which you strip out the username from the response
Dismiss any security setting from WCF all together (e.g. BasicHttpSecurityMode.None) and push the outgoing user/pass SOAP headers to the message by yourself (they are very simple xml elements) via a message inspector (easiest) or encoder or a custom header.
We have a WCF Service which will Upload and Download Documents to and from FileShare respectively.
The client application will pass a FileShareLocation and FileName inthe request.
But we are getting some exception, and not able to get the response.
FileSharePath sample : \\SERVERIP\SHAREDFOLDER
Note: The service is working fine when I don't use Network File Share.
'. ---> System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at wcfServiceTest.wcfService.ICommonService.UploadDocument(UploadDocumentRequest request)
at wcfServiceTest.wcfService.CommonServiceClient.wcfServiceTest.wcfService.ICommonService.UploadDocument(UploadDocumentRequest request) in D:\Test\CMS\wcfServiceTest\wcfServiceTest\Service References\wcfService\Reference.cs:line 2309
at wcfServiceTest.wcfService.CommonServiceClient.UploadDocument(RequestHeader UploadDocumentReqHdr, Byte[]& UploadDocumentContent) in D:\Test\CMS\wcfServiceTest\wcfServiceTest\Service References\wcfService\Reference.cs:line 2316
at wcfServiceTest.frmMain.DocumentUpload_Click(Object sender, EventArgs e) in D:\Test\CMS\wcfServiceTest\wcfServiceTest\frmMain.cs:line 105
Resolved by myself.
Create a new Application pool in IIS
Change Identity of AppPool to the User who has access to FileShare
Change the WCF Service Application Pool to the new Application Pool
I need to create wcf service for sharepoint 2010. The idea to use Jquery ajax to communicate with this service. But all cals to service methods always fail.
The
I try to use WCF Test Client and get message:
Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service.
and error detais:
The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 227 bytes of the response were: 'A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 - Either a required impersonation level was not provided, or the provided impersonation level is invalid.)'.
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at ITV2WCFService.DoWork()
at TV2WCFServiceClient.DoWork()
But service http://localhost/_vti_bin/site/TEMPSERVICE.svc/mex is avaliable and give me normal response.
Everything done according to article on msdn
http://msdn.microsoft.com/en-us/library/ff521581.aspx
Whats the problem and how to deal with it?
Evgeny:
It looks like your webservice returns standard SOAP XML response. JQuery expects to use JSON. I think the easier way is to set JQuery to use XML. Alternatively you can change your web service to return JSON instead of XML.
Solution: Anonymous access have to be enabled!