Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6366
  • Last Modified:

C# - WCF - "Failed to Invoke The Service"

I received the error in the title.  Can someone help me troubleshoot?

The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.

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 ITransferService.GetData(Int32 value)
   at TransferServiceClient.GetData(Int32 value)

*********************************************************

Here is the code

    [ServiceContract]
    public interface ITransferService
    {
       [OperationContract]
        string GetData(int value);
    }

    [Serializable]
    public class TransferService : ITransferService
    {
        public string GetData(int value)
        {
            return value.ToString();
        }
    }
0
CipherIS
Asked:
CipherIS
  • 8
  • 7
1 Solution
 
Gautham JanardhanCommented:
how are u hosting ur service , if it's in iis /webdev then try opening the svc file thru browser and see whats happening
0
 
BuggyCoderCommented:
Remove [Serializable] attribute from implementation and add service behaviour with exception details in faults turned on as:-

    [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    public class TransferService : ITransferService
    {
        public string GetData(int value)
        {
            return value.ToString();
        }
    }

Next on client try to invoke the service under try/catch block and see the exception that you get.
0
 
CipherISAuthor Commented:
@BuggyCoder - I implemented the changes you suggested.  This is the error I am receiving with the Try/Catch - Object reference not set to an instance of an object.

Some Info.  

I when I view the Transfer.svc in Browswer the web page comes up and gives me the URL with the ?wsdl.

I have two websites.

1.  ASP.NET website with add Service Reference using http://blahblahblah/transfer.svc
2.  ASP.NET webiste with add Service Reference using discovery (localhost)

When testing the ASP.NET website that is calling the WCF using localhost I have no issues.
When testing the ASP.NET website using http I am receiving this error.

Also, I run the WCFTestClient an enter the endpoint address:  http://XXX.XXX.XXX.XXX/APIHost/Transfer.svc I can see all the methods that are in the WCF app.  I click on Get Data and enter a value "5" and click on Invoke then I get the below error:

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.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
BuggyCoderCommented:
the error means that your are trying to access a disposed object on server side.
Try to debug the service and see where the error is, Fixing the error on server side will fix your issue definitely....

also make sure that all the service side code is handled for exceptions....
0
 
CipherISAuthor Commented:
Can't debug the service when adding it with http://xxx.xxx.xxx.xxx./transfer.svc.

I debug with http://localhost:xxxx/transfer.svc - I can debug and there are no issues at all.  I put code i the WCF to write to a text file and text file is not creatd at all.
0
 
BuggyCoderCommented:
please share the code for svc method that you are calling.
I hope there is try catch block on your svc method that you are calling...
0
 
CipherISAuthor Commented:
Here is my WCF code.

namespace TransferService
{
    [ServiceContract]
    public interface ITransferService
    {
       [OperationContract]
        string GetData(int value);
    }
}

namespace TransferService
{
    [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    public class TransferService : ITransferService
    {

        //For Testing Purposes
        public string GetData(int value)
        {
            try
            {
                return value.ToString();
            }
            catch (Exception ex)
            {
                return = ex.Message.ToString();
           }
        }
}
0
 
BuggyCoderCommented:
this looks fine, let me know how are you calling it from client, which binding etc.
0
 
CipherISAuthor Commented:
Here is a portion of the web.config

   <basicHttpBinding>
    <binding name="BasicHttpBinding_ITransferService"
              closeTimeout="04:01:00" openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00"
              allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
              maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
              messageEncoding="Text" textEncoding="utf-8" transferMode="StreamedRequest"
              useDefaultWebProxy="true">
    <readerQuotas maxDepth="2147483647"
                  maxStringContentLength="2147483647"
                  maxArrayLength="2147483647"
                  maxBytesPerRead="2147483647"
                  maxNameTableCharCount="2147483647"/>
     <security mode="None">
      <transport clientCredentialType="None" proxyCredentialType="None"
       realm="" />
      <message clientCredentialType="UserName" algorithmSuite="Default" />
     </security>
    </binding>
   </basicHttpBinding>
  </bindings>
            <client>
   <endpoint address="http://1xxx.xxx.xxx.xxx/APIFulfillmentHost/Transfer.svc/basic"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITransferService"
    contract="MDRTransferServiceReference.ITransferService" name="BasicHttpBinding_ITransferService" />
  </client>
      </system.serviceModel>
0
 
CipherISAuthor Commented:
Here is code on client

            ITransferService Test= new ransferServiceClient();
           string s = Test.GetData(5);

Above code works when I do Add Service Reference Discover but when I actualy type the http://xxx.xxx.xxx.xxx/Transfer.svc it finds my WCF Service but the code above blows up.
0
 
BuggyCoderCommented:
How are you hosting this service, inside IIS or is self hosted.
Because if it is self hosted, then you have to use netsh to add the address to allowed set of addresses...
0
 
CipherISAuthor Commented:
Inside IIS 7
0
 
BuggyCoderCommented:
are you still getting object reference not set to an instance of object error....
0
 
CipherISAuthor Commented:
yes - only when I bind it via Add Service Reference and type the URL and click on GO.  

If I use discover and bind it via localhost - no.
0
 
CipherISAuthor Commented:
Well - I have a solution.  I created a new WCF service and hosted it.  I am able to connect to that Service via IP and its working.  The original is not.  Don't know y the original works with everything else but IP.  So I will move my changes to the new one

Thanks for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 8
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now