具有类库的ASP.net Web服务 [英] ASP.net web service with Class library

查看:55
本文介绍了具有类库的ASP.net Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从类库中调用ASP.NET Web服务中的Web方法.两者都是同一个项目.最后由于错误而发生
''在服务模型客户端配置部分中找不到引用合同的默认端点元素.这可能是因为没有为您的应用程序找到配置文件,或者是在client元素中找不到与该协定匹配的终结点元素.''

请帮助我.

I Cant able to call web method IN ASP.NET web service from Class library.Both are Same Project.At last occurred following error
''Could not find default endpoint element that references contract in the Service Model client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.''


Please help me.

推荐答案

我的第一个选择是配置问题,如下所述:找不到默认端点元素 [ ^ ]
如果您在类库中调用服务并从另一个项目中调用类库,则可能会出现此错误."
在这种情况下,您需要将WS配置设置包括在主项目app.config(如果是winapp)或web.config(如果是web应用程序)中.即使使用PRISM和WPF/Silverlight,这也是要采用的方法.



因此,上面的链接中也可能提到了其他各种原因.
例如:对于网络参考,可能必须将URL作为第一个参数提供给构造函数.
My first bet would be on configuration issue, something as mentioned here: WCF Error - Could not find default endpoint element [^]
Copy the endpoint definitions from the config file (e.g. ServiceReferences.ClientConfig) of the class library to the config file of the silverlight application.

Similar thing mentioned here: Could not find default endpoint element[^]
"This error can arise if you are calling the service in a class library and calling the class library from another project."
In this case you will need to include the WS configuration settings into the main projects app.config if its a winapp or web.config if its a web app. This is the way to go even with PRISM and WPF/Silverlight.



As such, there can be various other reasons too that are mentioned in the link above.
Ex: it might be that for a web REFERENCE, you have to supply the URL as the first parameter to the constructor.


这篇关于具有类库的ASP.net Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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