views:

346

answers:

2

Whew! Ok… I solved my Wcf / Linq errors (and learned a lot – a series of blog posts will follow next weak). Now I need to deploy. We run on the Mosso / Rackspace cloud, and for the moment that environment runs in a partial trust environment.

To make it simple, I added a method to my Wcf service that does just about NOTHING.

public string Echo(string what)
{
    return what;
}

I built it all, and shipped it to the test server with the following Web.Config (relevant section only)… yes, I will need to add security obviously before exposing the dangerous methods, but for now I jsut want the anonymous stuff running :)

<system.serviceModel>
 <bindings>
   <basicHttpBinding>
       <binding name="BasicAnonymous">
           <security mode="None"/>                
       </binding>
   </basicHttpBinding>
</bindings>
 <behaviors>
  <serviceBehaviors>
   <behavior name="FooBar.Backend.Web.Services.CoreDataWcfServiceBehavior">
    <serviceMetadata httpGetEnabled="true" />
    <serviceDebug includeExceptionDetailInFaults="true" />
   </behavior>
  </serviceBehaviors>
 </behaviors>
 <services>
  <service behaviorConfiguration="FooBar.Backend.Web.Services.CoreDataWcfServiceBehavior"
   name="FooBar.Backend.Web.Services.CoreDataWcfService">
   <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicAnonymous" contract="FooBar.Backend.Web.Services.ICoreDataWcfService" />
   <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
 </services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
   <baseAddressPrefixFilters>
       <add prefix="http://backend.FooBar.com"/&gt;
   </baseAddressPrefixFilters>
</serviceHostingEnvironment>
</system.serviceModel>

So, off I go to call it in the simplest way I can with a console application. i add the service reference and it adds fine. Then I call it (I took inactive code for brevity)…

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; 

using CoreWcfHarness.CoreDataServiceReference; 

namespace CoreWcfHarness
{
    class Program
    {
        static void Main(string[] args)
        {
            var context = new CoreDataWcfServiceClient(); 

            var echoval = context.Echo("Hello World!");
            Console.WriteLine(String.Format("{0}\n", echoval));
            Console.ReadKey();
        }
    }
}

And blammo. I get hit with an exception.

System.ServiceModel.FaultException`1 was unhandled
  Message="Request failed."
  Source="mscorlib"
  StackTrace:
    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 CoreWcfHarness.CoreDataServiceReference.ICoreDataWcfService.Echo(String what)
       at CoreWcfHarness.CoreDataServiceReference.CoreDataWcfServiceClient.Echo(String what) in C:\PathToProject\corewcfharness\service references\coredataservicereference\reference.cs:line 1890
       at CoreWcfHarness.Program.Main(String[] args) in C:\PathToProject\CoreWcfHarness\Program.cs:line 42
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

This is about as simple as it gets. Anyone familiar with medium trust environments and / or good with a stack trace?

Thanks!

+1  A: 

"Request Failed" could be a number of things.

It looks like the most probable reason is that the request is not reaching the server. You should check the server logs to make sure that the request is being sent to the correct place.

Shiraz Bhaiji
Indeed, it wasn't reaching the right places.. the trust environment hated my codebase. I had to refactor over to ADO.NET Data services.
Soulhuntre
+1  A: 

Have you had any luck with this? I'm getting the same error but do not have access to the logs. Please post if you find a resolution.

Thanks.

They sent over some articles about runnign WCF in medium trust that looked useful and their support folks probably have a handle on it now.Partial Trust: WPF Calling WCF Using a BasicHttpBinding http://msdn.microsoft.com/en-us/library/bb943481.aspxPartial Trust: WPF Calling WCF Using a WSHttpBinding http://msdn.microsoft.com/en-us/library/bb943482.aspxBut no, i never got it working. I went to ADO.NET Data Services.
Soulhuntre