0
votes

I have a WCF service that uses a reference to a class library. Classes in that library do things like interact with a database. I was testing my service (which compiles with no errors) using restful calls through a browser and it just displays a page that simply says "Endpoint not found.". I'm assuming that this is related to the fact that the library has references to connection strings and appsettings etc (which i normally have to include in the applications that use this library). So what I'm having trouble finding is how to properly configure the wcf service to work with this library. I tried simply adding the connection strings and appsetings to the wcf web.config but that doesn't seem to help. I feel like it is just about adding reference to the library through the endpoint section of the service. But I'm lost there. Any help is appreciated. Thanks

<system.serviceModel>
    <services>
      <service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehavior">
        <endpoint address="" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="web">

        </endpoint>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name ="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

UPDATE: Running the trace, this is the stack trace from the exception being thrown:

System.ServiceModel.Dispatcher.HttpUnhandledOperationInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet) System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext request, Boolean cleanThread, OperationContext currentOperationContext) System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext request, OperationContext currentOperationContext) System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult result) System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyncResult result) System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result) System.Runtime.AsyncResult.Complete(Boolean completedSynchronously) System.Runtime.InputQueue1.AsyncQueueReader.Set(Item item) System.Runtime.InputQueue1.EnqueueAndDispatch(Item item, Boolean canDispatchOnThisThread) System.Runtime.InputQueue1.EnqueueAndDispatch(T item, Action dequeuedCallback, Boolean canDispatchOnThisThread) System.ServiceModel.Channels.SingletonChannelAcceptor3.Enqueue(QueueItemType item, Action dequeuedCallback, Boolean canDispatchOnThisThread) System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext context, Action callback) System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult result) System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest() System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest() System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object state) System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped) System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped) System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

1
Endpoint not found is related to your WCF config, which you haven't provided.BNL
updated. Apologies in advance if I seem vague. It is simply because I'm not exactly sure how to ask the questionSinaesthetic
I've not worked with wcf rest, so I'm not of much help, but you should probably also post your c# method definitions and the URL you are trying to load.BNL
Not Found errors don't always mean not found. If an exception occurs in the right spot in the service channel, you can get a "Not Found" exception. Try turning on WCF tracing. It is really verbose, so I don't recommend leaving it on, but it will give you plenty of details. msdn.microsoft.com/en-us/library/ms733025.aspxcadrell0
There was an exception caught in the trace. however, it doesn't say what it really is, just System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. This error only occurs when the library is used by the service. I have no problems in other applications.Sinaesthetic

1 Answers

0
votes

ok so I got it working. It APPEARED to be an issue with the host address. I recreated the project as a Service Library instead of a Service Application and I noticed a couple new fields in the default config. One of which was for the host. When I set the base address, everything started working just hunkydory. Here is the config:

<system.serviceModel>
<services>
  <service name="ServiceWithLibraryTest.UtiService">
    <endpoint address="" binding="webHttpBinding" contract="ServiceWithLibraryTest.IUtiService" behaviorConfiguration="web" />        
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8732/ServiceWithLibraryTest/UtiService/"/>
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="True"/>
      <serviceDebug includeExceptionDetailInFaults="False"/>
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="web">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
</behaviors>

I'm kind of new to WCF and from what I understand, it is notorious for the config constantly being a head scratcher. I'm still working on wrapping my head around endpoints, but I'm starting to get a better understanding of how endpoints are just the means of exposing the service and behaviors being how they are communicated. Then of course, rest services add a whole new layer to that. I appreciate the thoughts :)