Error: Timeouts are not supported on this stream in Web Api - c#

I have a api controller to recieve bunch of data from a webservice and translate it to a JSON.
When it fetches larger data pack, an error occures:
Timeouts are not supported on this stream
My controller is pretty simple:
public class ChangesPickupController : ApiController
{
[HttpPost]
public ChangeStructure[] GetChangesPickup(string id, int page, int toPage, UserInfoStructure uis)
{
var manager = new CkpClientManager();
try
{
var dt = DateTime.ParseExact(id, "yyyyMMddHHmmss", CultureInfo.InvariantCulture);
using (var client = manager.GetClient())
{
return client.GetChanges(uis, dt, page, toPage);
}
}
catch (Exception ex)
{
Console.WriteLine("ERROR: " + ex.Message);
throw new Exception(ex.Message);
}
}
}
Do you have any clue, what might be a problem? Should I change some attributes for streaming somewhere or what?
Thanks in advance, JiKra
EDIT:
Well, here is my stack:
Server stack trace:
at System.IO.Stream.get_ReadTimeout()
at System.ServiceModel.Channels.DelegatingStream.get_ReadTimeout()
at System.ServiceModel.Channels.DelegatingStream.get_ReadTimeout()
at System.ServiceModel.Channels.HttpInput.WebResponseHttpInput.WebResponseInputStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.ServiceModel.Channels.MessageEncoder.BufferMessageStream(Stream stream, BufferManager bufferManager, Int32 maxBufferSize)
at System.ServiceModel.Channels.MessageEncoder.ReadMessage(Stream stream, BufferManager bufferManager, Int32 maxBufferSize, String contentType)
at System.ServiceModel.Channels.HttpInput.ReadChunkedBufferedMessage(Stream inputStream)
at System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(HttpRequestMessage httpRequestMessage, Exception& requestException)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, 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.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 CkpSelfHost3.CkpWs.ICkpWS.GetChangesPickup(UserInfoStructure UserInfo, DateTime Datum, Int32 Strana, Int32 NaStranu)
at CkpSelfHost3.CkpWs.CkpWSClient.GetChangesPickup(UserInfoStructure UserInfo, DateTime Datum, Int32 Strana, Int32 NaStranu) in C:\Users\krakora\documents\visual studio 20
Host3\CkpSelfHost3\Service References\CkpWs\Reference.cs:line 2576
at CkpSelfHost3.Controllers.ChangesPickupController.GetChangesPickup(String id, Int32 page, Int32 toPage, UserInfoStructure uis) in C:\Users\krakora\documents\visual studio 2
fHost3\CkpSelfHost3\Controllers\ChangesPickupController.cs:line 30

Well, the problem was on the vendor's side in webservice provider.
JiKra

Related

C# soap client System.OverflowException: Arithmetic operation resulted in an overflow

928mb file works ok, but this overflow error happens when I try to send 1.08GB to the soap service (mtom chunked transfer, _service reference.cs is generated from wsdl). In the fiddler tracing I see only headers of the request, but no request body and no response
Relevant code:
var httpsTransportBindingElement = new HttpsTransportBindingElement
{
MaxReceivedMessageSize = int.MaxValue,
TransferMode = TransferMode.Streamed //Chunked transfer
};
var binding = new CustomBinding();
var mtomEncoding = new MtomMessageEncodingBindingElement(MessageVersion.Soap12, Encoding.UTF8);
mtomEncoding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
binding.Elements.Add(mtomEncoding);
binding.Elements.Add(httpsTransportBindingElement);
binding.SendTimeout = TimeSpan.FromHours(1);
binding.ReceiveTimeout = TimeSpan.FromMinutes(5);
_service = new FileuploadSoapPortTypeClient(binding, new EndpointAddress(configuration.HttpUploadUrl));
_service.PostFile(request);
And the error stacktrace is as follows:
System.OverflowException: Arithmetic operation resulted in an overflow.
Server stack trace:
at System.IO.BufferedStream.Write(Byte[] array, Int32 offset, Int32 count)
at System.Xml.XmlMtomWriter.WriteXOPBinaryParts()
at System.ServiceModel.Channels.Message.WriteMessagePostamble(XmlDictionaryWriter writer)
at System.ServiceModel.Channels.MtomMessageEncoder.WriteMessage(Message message, Stream stream, String startInfo, String boundary, String startUri, Boolean writeMessageHeaders)
at System.ServiceModel.Channels.HttpOutput.WriteStreamedMessage(TimeSpan timeout)
at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, 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 MyServiceClient.FileuploadSoapPortType.PostFile(UploadRequest request)
at MyServiceClient.FileuploadSoapPortType.PostFile(UploadRequest request) in C:\MyServiceClient\Reference.cs:line 8473
I cant debug this further than to the PostFile() call, so my question is - where does the error occur, in the server or on my client? and of course how to go about fixing it? Thanks!
From in the stack trace it is telling you that it is server side:
Server stack trace:
The error is caused by something which is happening at:
at MyServiceClient.FileuploadSoapPortType.PostFile(UploadRequest request) in C:\MyServiceClient\Reference.cs:line 8473
Access that file and see what is happening on that line. I'd like to think where ever the web service is hosted they have logs for when something like this occurs.
To find out why I suggest:
giving the time it occured ( if they have logs its easier to find the stack trace)
Detailed description of what you tried to do when the error occurred.

Exception : ProtocolException was unhandled by user code

Please help me on below error : The exception is being thrown while consuming the service using client code
Exception Details: System.Net.WebException: The remote server returned an error: (405) Method Not Allowed.
using (var customerCreditService = new CustomerCreditServiceClient())
{
var creditLimit = customerCreditService.GetCreditLimit(customer.Firstname,
customer.Surname, customer.DateOfBirth);
(**Exception thrown while calling this method**)
}
Error Message : The remote server returned an unexpected response: (405) Method Not Allowed.
Stack Trace : Server stack trace:
at >System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory1 factory, WebException responseException, ChannelBinding channelBinding) at
System.ServiceModel.Channels.HttpChannelFactory1.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 App.ICustomerCreditService.GetCreditLimit(String firstname, String surname, DateTime dateOfBirth)
at App.CustomerCreditServiceClient.GetCreditLimit(String firstname, String surname, DateTime dateOfBirth) in
\App\CustomerCreditService.cs:line 53
at App.Customer.doCreditCheck(Customer customer) in
\App\Customer.cs:line 36
at App.SilverCustomer.doCreditCheck(Customer customer) in \App\SilverCustomer.cs:line 14
at App.CustomerService.AddCustomer(Customer customer) in \App\App\CustomerService.cs:line 64
at App.Tests.CustomerUnitTests.AddCustomer_DoCreditCheck_ForSilver() in \App.Tests\CustomerUnitTests.cs:line 74

NetNamedPipeBinding channel.State == Opened but failing

I have am working on an application which uses NetNamedPipeBinding to communicate between a WSDualHttpBinding WCF service (ServiceA) and a Windows service (ServiceB) which are both on the same machine.
I have a proxy class in ServiceA which creates a ChannelFactory and, subsequently, the NetNamedPipe Channel. This channel is then cached and is used for all communications with ServiceB.
Basically, whenever I need to make a call using the NetNamedPipeBinding service, I get the ChannelProxy like this:
private ManagerProxy _managerProxy;
private ManagerProxy managerProxy
{
get
{
lock (lockObj)
{
if (_managerProxy == null)
{
LogWarning("managerProxy", "_managerProxy == null. Creating proxy.");
_managerProxy = new ManagerProxy();
}
else if (_managerProxy != null && (_managerProxy.State == CommunicationState.Closed || _managerProxy.State == CommunicationState.Closing || _managerProxy.State == CommunicationState.Faulted))
{
LogError("managerProxy", string.Format("_managerProxy.State == {0}. Attempting to renew proxy.", _managerProxy.State.ToString()), null, (int)ErrorReference.ProxyFaultedOrClosed);
try
{
_managerProxy.Close();
}
catch (Exception ex)
{
//Log exception;
}
_managerProxy = null;
_managerProxy = new ManagerProxy();
}
EventLog.WriteEntry("managerProxy", string.Format("ManagerProxy's State == {0}", _managerProxy.State), EventLogEntryType.Information);
}
return _managerProxy;
}
}
Now, 99% of the time, everything works fine, but occasionally, I'll get that last line in the log - ManagerProxy's State == Opened. Immediately after this check, I attempt to call a method using the proxy and I get the following error:
Action on the channel failed.
System.ServiceModel.CommunicationException: There was an error writing to the pipe: The pipe is being closed. (232, 0xe8).
---> System.IO.IOException: The write operation failed, see inner exception.
---> System.ServiceModel.CommunicationException: There was an error writing to the pipe: The pipe is being closed. (232, 0xe8).
---> System.IO.PipeException: There was an error writing to the pipe: The pipe is being closed. (232, 0xe8).
at System.ServiceModel.Channels.PipeConnection.StartSyncWrite(Byte[] buffer, Int32 offset, Int32 size, Object& holder)
at System.ServiceModel.Channels.PipeConnection.WriteHelper(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout, Object& holder)
--- End of inner exception stack trace ---
at System.ServiceModel.Channels.PipeConnection.WriteHelper(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout, Object& holder)
at System.ServiceModel.Channels.PipeConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
at System.ServiceModel.Channels.BufferedConnection.WriteNow(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, BufferManager bufferManager)
at System.ServiceModel.Channels.BufferedConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
at System.ServiceModel.Channels.ConnectionStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.NegotiateStream.StartWriting(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.NegotiateStream.ProcessWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
--- End of inner exception stack trace ---
at System.Net.Security.NegotiateStream.ProcessWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.NegotiateStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.ServiceModel.Channels.StreamConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.Channels.StreamConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
at System.ServiceModel.Channels.StreamConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout, BufferManager bufferManager)
at System.ServiceModel.Channels.FramingDuplexSessionChannel.OnSendCore(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.TransportDuplexSessionChannel.OnSend(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.OutputChannel.Send(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.DuplexChannelBinder.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 [My code] [line]
Why do I get State == Opened and immediately afterwards failure to write to the pipe?
Is there maybe some architectural change I should make to the way I keep my ProxyChannel?

Is there a maximum Time Stamp Validity Duration when a client is set to a future datetime vs the server

We set our Security on our custom Binding as below:
var lSecurity = lCustomBinding.Elements.Find<TransportSecurityBindingElement>();
lSecurity.LocalClientSettings.DetectReplays = false;
lSecurity.LocalServiceSettings.DetectReplays = false;
lSecurity.LocalClientSettings.TimestampValidityDuration = TimeSpan.FromDays(7);
lSecurity.LocalServiceSettings.TimestampValidityDuration = TimeSpan.FromDays(7);
lSecurity.LocalClientSettings.MaxClockSkew = TimeSpan.FromDays(7);
lSecurity.LocalServiceSettings.MaxClockSkew = TimeSpan.FromDays(7);
Now we find that if we test the above by setting the client back anywhere from now to 7 days back, it works. However, the moment we set the client anything more than 9 hours into the future, we get an exception.
The only thing we found was some obscure reference at the end of another thread:
http://social.msdn.microsoft.com/Forums/en/wcf/thread/7c3a7a7e-b9a5-4198-9a29-c6d4e408d36d
Does anybody have any ideas?
UPDATE:
The Exception we get is now added below. It seems as though the server rejects the client message:
System.ServiceModel.Security.MessageSecurityException occurred
Message=An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.
Source=mscorlib
StackTrace:
Server stack trace:
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.Security.SecuritySessionSecurityTokenProvider.DoOperation(SecuritySessionOperation operation, EndpointAddress target, Uri via, SecurityToken currentToken, TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.RenewTokenCore(TimeSpan timeout, SecurityToken tokenToBeRenewed)
at System.IdentityModel.Selectors.SecurityTokenProvider.RenewToken(TimeSpan timeout, SecurityToken tokenToBeRenewed)
at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.RenewKey(TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.SecureOutgoingMessage(Message& message, TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecurityDuplexSessionChannel.Send(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.DuplexClientReliableChannelBinder`1.OnSend(TDuplexChannel channel, Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ReliableChannelBinder`1.Send(Message message, TimeSpan timeout, MaskingMode maskingMode)
at System.ServiceModel.Channels.SendReceiveReliableRequestor.OnRequest(Message request, TimeSpan timeout, Boolean last)
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.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 CompuLoan.Maintenance.IMaintenanceService.IsLicensed(String pHardwareId, Boolean pUseLicense)
at CompuLoan.Maintenance.MaintenanceServiceClient.IsLicensed(String pHardwareId, Boolean pUseLicense) in C:\Development\compuloan\Source\CompuLoan\Service References\Maintenance\Reference.cs:line 5156
at CompuLoan.App.IsLicensed(Boolean pUseLicense) in C:\Development\compuloan\Source\CompuLoan\App.xaml.cs:line 365
InnerException: System.ServiceModel.FaultException
Message=The security context token is expired or is not valid. The message was not processed.
InnerException:
This is expiration of the session key, which is different than timestamp. For example of you turn establishSecurityContext off (or not use CreateSecureConversationSecurity) you should not get this exception.
Otherwise try to increase additional values such as InactivityTimeout, IssuedCookieLifetime, NegotiationTimeout, SessionKeyRenewalInterval and SessionKeyRolloverInterval.
If you turn on WCF trace on the server and see the exact stack trace of the error maybe we can dril down to the exact property.

Need to provide a way to connect to multiple SOAP Endpoints programmatically

Given:
Multiple clients with a Service.asmx page that has some web methods that I need to connect to.
A Utility function that takes input to determine which client needs to be connected to. This is what I have so far:
public static MyServiceSoapClient SoapClientFactory(string clientCode)
{
var binding = new WSHttpBinding(SecurityMode.Message, false);
var remoteAddress = new EndpointAddress(
new Uri(string.Format("http://{0}.mydomain.com/Service.asmx", clientCode)),
new UpnEndpointIdentity("myservice#domain.com"));
return new MyServiceSoapClient(binding, remoteAddress);
}
This method completes with no errors (note: I don't know what the EndPointIdentity is so I just came up with a string to put in there... not sure if this should be in a config setting somewhere else or what?)
Problem:
While trying to make the call to the remote method, an exception is thrown and its not very descriptive (A NullReferenceException). Here's the code:
// point to the correct Service.asmx url.
var client = Util.SoapClientFactory(clientCode);
// now make the soap call.
var result = client.GetSomeStuff(someParameter); // throws the exception.
The stack trace:
System.NullReferenceException: Object reference not set to an instance of an object.
Server stack trace:
at System.ServiceModel.Security.IssuanceTokenProviderBase`1.DoNegotiation(TimeSpan timeout)
at System.ServiceModel.Security.SspiNegotiationTokenProvider.OnOpen(TimeSpan timeout)
at System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Security.CommunicationObjectSecurityTokenProvider.Open(TimeSpan timeout)
at System.ServiceModel.Security.SecurityUtils.OpenTokenProviderIfRequired(SecurityTokenProvider tokenProvider, TimeSpan timeout)
at System.ServiceModel.Security.SymmetricSecurityProtocol.OnOpen(TimeSpan timeout)
at System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.SecurityChannelFactory`1.ClientSecurityChannel`1.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.DoOperation(SecuritySessionOperation operation, EndpointAddress target, Uri via, SecurityToken currentToken, TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.GetTokenCore(TimeSpan timeout)
at System.IdentityModel.Selectors.SecurityTokenProvider.GetToken(TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.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 ... my function call. (i.e. client.GetSomeStuff(someParameter) )
I found the answer to my problem. What I do is I create a Soap client using the default constructor (this always works but then im stuck with the Uri that I've configured during development) What I do then is set the Endpoint's Address property it worked like a charm!
var client = new MySoapClient();
// this can also be set using Web.config parameter now or a value stored in a database etc.
client.Endpoint.Address = new EndpointAddress("http://localhost:3000/Service.asmx");
return client;

Categories