一个简单的WCF示例服务 [英] A Simple Sample WCF Service

查看:50
本文介绍了一个简单的WCF示例服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我关注了您关于代码项目的文章,并遇到以下问题.

WCF服务主机对话框显示
1)存储BookService错误,没有元数据.有关更多信息,请参见* 1.
2)WcfServiceLibrary1启动没有错误.
2)代码在Form1.cs中的第58行停止.请参阅* 2.如果我将SampleDB.xml文件放在c:\ windows \ system32 \ inetsrv \中,它将起作用.
TIA
约翰

Hi,
I followed your article on code project and get the following issues.

THE WCF Service Host dialog box shows
1) Store BookService Error with no metadata. See *1 for additional info.
2) WcfServiceLibrary1 started with not errors.
2) The code stops in Form1.cs at line 58. See *2. If I put the SampleDB.xml file in c:\windows\system32\inetsrv\, it works.
TIA
John

lstBooks = bookService.Filter(Author: txtAuthor.Text, Title: TxtTitle.Text, Genre: strGenre);





* 1
System.InvalidOperationException:找不到与绑定BasicHttpBinding的端点匹配方案http的基地址.注册的基址方案为[].
在System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri,绑定绑定,UriSchemeKeyedCollection baseAddresses)中
在System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase主机,ServiceDescription描述,ServiceElement serviceElement,Action`1 addBaseAddress)中
在System.ServiceModel.ServiceHostBase.ApplyConfiguration()
在System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)中
在System.ServiceModel.ServiceHost..ctor(类型serviceType,Uri [] baseAddresses)
在Microsoft.Tools.SvcHost.ServiceHostHelper.CreateServiceHost(类型,类型,ServiceKind)
在Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo信息)

* 2
未处理System.ServiceModel.FaultException`1
消息=找不到文件``c:\ windows \ system32 \ inetsrv \ SampleDB.xml''.
来源= mscorlib
StackTrace:
服务器堆栈跟踪:
在System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(消息回复,MessageFault错误,字符串操作,MessageVersion版本,FaultConverter faultConverter)
在System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime操作,ProxyRpc& rpc)处
在System.ServiceModel.Channels.ServiceChannel.Call处(字符串操作,布尔型单向,ProxyOperationRuntime操作,Object [] ins,Object [] outs,TimeSpan超时)
...





*1
System.InvalidOperationException: Could not find a base address that matches scheme http for the endpoint with binding BasicHttpBinding. Registered base address schemes are [].
at System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri, Binding binding, UriSchemeKeyedCollection baseAddresses)
at System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress)
at System.ServiceModel.ServiceHostBase.ApplyConfiguration()
at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)
at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)
at Microsoft.Tools.SvcHost.ServiceHostHelper.CreateServiceHost(Type type, ServiceKind kind)
at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info)

*2
System.ServiceModel.FaultException`1 was unhandled
Message=Could not find file ''c:\windows\system32\inetsrv\SampleDB.xml''.
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)
...

推荐答案

为更清晰起见,您需要共享代码.

在分析给定的两个错误时,建议的根本原因如下:

1.尝试将安全模式从传输"更改为无".或验证http连接的安全性部分.

2.看来您的WCF服务需要"c:\ windows \ system32 \ inetsrv \ SampleDB.xml"文件,该文件已丢失.
For better clarity, you need to share the code.

On analysing the given two errors, the suggested root cause as below:

1. Try changing the security mode from Transport to none. Or verify the security part of http connection.

2. Looks like your WCF service needs ''c:\windows\system32\inetsrv\SampleDB.xml'' file, which is missing.


这篇关于一个简单的WCF示例服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆