Exception : ProtocolException was unhandled by user code - c#

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

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.

Unmarshalling Error: Namespace URIs and local names to the unmarshaller needs to be interned

I've created a web reference to a SOAP web service in C#.
If i browse to the service or use POSTMAN for example to test i get back a response as expected.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:openResponse xmlns:ns1="http://auto.api.com/">
<return xmlns:ns2="http://auto.api.com/">
<error>User/pass incorrect</error>
</return>
</ns1:openResponse>
</soap:Body>
</soap:Envelope>
The code I am running below is quite simple, but when its connecting to the service i'm getting this error:
Unmarshalling Error: Namespace URIs and local names to the
unmarshaller needs to be interned
var connect = new SOAP();
var open = connect.open(new Open
{
user = "user",
pass = "pass"
});
Any suggestions? I cant find anything that suggests how to sort it out. I've never seen this error connecting to a web service before.
Full Exception:
System.Web.Services.Protocols.SoapHeaderException: Unmarshalling
Error: Namespace URIs and local names to the unmarshaller needs to be
interned. at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean
asyncCall) at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters) at
TestingConsole.web.SOAP.open(xOpen open1) in
c:\Users\pm\Source\Repos\TestingConsole\Web
References\web\Reference.cs:line 755 at
TestingConsole.Form1.button1_Click(Object sender, EventArgs e) in
c:\Users\pm\Source\Repos\TestingConsole\Form1.cs:line 32
And part of reference.cs it is referring to
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="http://auto.api.com/", ResponseNamespace="http://auto.api.com/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("return", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public xOpenResponse open([System.Xml.Serialization.XmlElementAttribute("open", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] xOpen open1) {
object[] results = this.Invoke("open", new object[] {
open1});
return ((xOpenResponse)(results[0]));
}
Full exception as a service reference:
System.ServiceModel.FaultException: Unmarshalling Error: Namespace
URIs and local names to the unmarshaller needs to be interned.
Server stack trace: 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.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 TestingConsole.SOAP.open(open request)
at TestingConsole.SOAP.TestingConsole.SOAP.open(open request) in
c:\Users\pm\Source\Repos\TestingConsole\Service
References\service\Reference.cs:line 7621 at
TestingConsole.SOAP.open(xOpen open1) in
c:\Users\pm\Source\Repos\TestingConsole\Service
References\service\Reference.cs:line 7627 at
TestingConsole.Form1.button1_Click(Object sender, EventArgs e) in
c:\Users\pm\Source\Repos\TestingConsole\Form1.cs:line 29
And the bits from the reference.cs file its referring to:
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
TestingConsole.service.openResponse TestingConsole.service.SOAP.open(TestingConsole.service.open request) {
return base.Channel.open(request);
}
public TestingConsole.service.xOpenResponse open(TestingConsole.service.xOpen open1) {
TestingConsole.service.open inValue = new TestingConsole.service.open();
inValue.open1 = open1;
TestingConsole.service.openResponse retVal = ((TestingConsole.service.SOAP)(this)).open(inValue);
return retVal.#return;
}
The answer to fix this was to remove the RequestNamespace from the methods it generated in the Reference.cs. This then meant it sent the correctly formatted request to the service
For me, this was solved by blanking the WrapperNamespace attribute parameter, so for example:
[System.ServiceModel.MessageContractAttribute(WrapperName="confirmReservation", WrapperNamespace="http://autogenerated.OTWebServiceApi.sampleservice.com/", IsWrapped=true)]
becomes
[System.ServiceModel.MessageContractAttribute(WrapperName="confirmReservation", WrapperNamespace="", IsWrapped=true)]

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

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

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