我可以直接从WCF中的对象调用方法吗 [英] Can I call a method directly from an object in WCF

查看:59
本文介绍了我可以直接从WCF中的对象调用方法吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出是否有可能在不使用服务客户端的情况下直接在WCF服务内的对象上调用方法.与应用webmethod属性的方式几乎相同.我可以通过我的服务创建一个类的实例 参考,例如:

I'm trying to find out if it is possible to call methods directly on objects within a WCF service without using the service client. Much the same way that you would do by applying the webmethod attribute. I can create an instance of a class from my service reference, for example:

ServiceReference.MyClass class =新的ServiceReference.MyClass();

ServiceReference.MyClass class = new ServiceReference.MyClass();

MyClass的属性为[ServiceContract],我要使用的方法的属性为[OperationContract]

MyClass is attributed with [ServiceContract] and the method I want to consume is attributed with [OperationContract]

执行此操作时,我可以看到对象上的任何属性,但是看不到任何方法.我花了一天时间寻找答案,但到目前为止还没有喜悦.我必须始终通过服务客户端界面显示这些方法,还是我要尝试的方法? 尽一切可能吗?

When I do this I can see any properties on the object but I can't see any of the methods. I've spent a day looking for an answer on this but so far no joy. Must I always surface these methods through the service client interface or is what I'm trying to do in any way possible?

非常感谢

推荐答案

>>我试图找出是否有可能在不使用服务客户端的情况下直接在WCF服务内的对象上调用方法.

>>I'm trying to find out if it is possible to call methods directly on objects within a WCF service without using the service client.

您可以在此处提供一些代码段以更好地解释您的问题吗?

Can you provide some code snippets here to better explain your issue?

您可以利用 WcfTestClient.exe 在不创建客户端应用程序的情况下测试服务.

You can utilize WcfTestClient.exe to test the service without creating a client application.

最好的问候.


这篇关于我可以直接从WCF中的对象调用方法吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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