我有一个使用对类库的引用的WCF服务。该库中的类可以执行与数据库交互等操作。我正在通过浏览器使用restful调用来测试我的服务(编译没有错误),它只显示一个简单地说“Endpoint not found。”的页面。我假设这与库引用连接字符串和appsettings等(我通常必须包含在使用此库的应用程序中)这一事实有关。所以我找不到的是如何正确配置wcf服务以使用此库。我尝试简单地将连接字符串和appsetings添加到wcf web.config,但这似乎没有帮助。我觉得这只是通过服务的端点部分添加对库的引用。但我迷失在那里。任何帮助表示赞赏。感谢
<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>
更新: 运行跟踪,这是抛出异常的堆栈跟踪:
System.ServiceModel.Dispatcher.HttpUnhandledOperationInvoker.Invoke(Object instance,Object [] inputs,Object []&amp; outputs)
System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&amp; rpc)
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp; 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结果)
System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyncResult结果)
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult结果)
System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
System.Runtime.InputQueue 1.AsyncQueueReader.Set(Item item)
System.Runtime.InputQueue
1.EnqueueAndDispatch(Item item,Boolean canDispatchOnThisThread)
System.Runtime.InputQueue 1.EnqueueAndDispatch(T item, Action dequeuedCallback, Boolean canDispatchOnThisThread)
System.ServiceModel.Channels.SingletonChannelAcceptor
3.Enqueue(QueueItemType项,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错误,UInt32 bytesRead,NativeOverlapped * nativeOverlapped)
System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode,UInt32 numBytes,NativeOverlapped * pOVERLAP)
答案 0 :(得分:0)
<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>
我对WCF不熟悉,据我所知,配置不断成为一个令人头疼的问题是臭名昭着的。我仍在努力绕过端点,但我开始更好地理解端点是如何暴露服务和行为的方式。当然,休息服务会为此添加一个全新的层。我很欣赏这些想法:)