从类库使用Web服务在asp.net应用 [英] Consume web service in asp.net app from a class library

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

问题描述

我和我的团队有一个asp.net web表单应用程序,并使用多个类库。在这些图书馆之一,我们试图使用Web服务。在Web应用程序项目中添加Web引用,并已加入适当的引用。该应用程序编译。当试图消耗类库中说Web服务,凭据似乎没有工作,调用失败。但是,如果我们把Web服务调用出来的类库,以及Web应用程序中使用它,它的工作原理。

My team and I have a asp.net web forms application and are using several class libraries. In one of those libraries, we are trying to consume a web service. The web reference was added in the web app project and the appropriate references have been added. The app compiles. When attempting to consume said web service in the class library, the credentials don't seem to work, and the call fails. However, if we take the web service call out of the class library, and consume it within the web app, it works.

这是为什么不类库中工作的任何想法。

Any ideas why this is not working in the class library.

推荐答案

可能是你叫错了!
下面是一个例子:

May be you called it wrong!! Here is an example:

var serviceName = new ServiceName
    {
        Credentials = new NetworkCredential("Username", "Password", "Domain"),
        Url = "Here you put the correct url of the web service if you published somewhere else"
    };
serviceName.CallWebMethod();

请确保您输入了正确的凭据的用户名和密码,并确认您发布的web服务,你访问它的地方。

make sure that you entered the correct Credential username and password and make sure the you published the webservice to a place you access it.

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

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