封装webservice代理以隐藏复杂性 [英] encapsulating webservice proxy to hide complexity

查看:68
本文介绍了封装webservice代理以隐藏复杂性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要部署一个.NET内部与WS通信的.NET DLL。我不希望其他人看到网络服务的内部复杂性
由添加网络参考产生的
类VS选项。

由于WebSerive包含很多方法和不同类型创建

a手动代理类太耗时。


我试图手动编辑一个类,从公共到内部更改最高级别访问

修饰符 - 这样我可以使用DLL中的类

,仅公开我的API。但是,这不能正常工作

- 某些这些类必须是公共的(例如,一个类

定义为SoapHeader,但不仅仅是) - 当将访问权限更改为内部时,我得到了一个错误 ;当尝试创建Web代理的实例时,方法XXX无法反映

...


所以问题是:

a)我在哪里可以找到一些信息在代理类生命周期中用什么来完成.NET框架

b)还有其他任何方法(最好是自动的) ...)从代理类中尽可能多地隐藏

信息?

谢谢

I''m to deploy a .NET DLL which internally communicates with the WS. I
don''t want others to see internal complexity of the web service
classes generated by "Add a Web reference" VS option.
As a WebSerive contains a lot of methods and different types creating
a web proxy class manually is too time consuming.

I tried to edit a class manually, changing the highest-level access
modifiers from public to internal - this way I could use the classes
from within the DLL, exposing only my API. However, this does not work
correctly - "some" of the classes have to be public (e.g. a class
defined as a SoapHeader, but not only) - when changing the access
modifier to internal, I got an error "Method XXX can not be reflected"
when trying to create an instance of the web proxy...

So the question is:
a) where could I find some information what is exactly done by
hte .NET framework during a proxy class lifetime
b) is there any other method (preferably automatic...) to hide as much
information as possible from the proxy class?
Thanks

推荐答案

" roberto" < ro **************** @ gmail.com写信息

新闻:11 ************** ********@u30g2000hsc.googlegr oups.com ...
"roberto" <ro****************@gmail.comwrote in message
news:11**********************@u30g2000hsc.googlegr oups.com...

我要部署一个.NET内部与WS通信的.NET DLL 。我不希望其他人看到网络服务的内部复杂性
由添加网络参考产生的
类VS选项。

由于WebSerive包含很多方法和不同类型创建

a手动代理类太耗时。


我试图手动编辑一个类,从公共到内部更改最高级别访问

修饰符 - 这样我可以使用DLL中的类

,仅公开我的API。但是,这不能正常工作

- 某些这些类必须是公共的(例如,一个类

定义为SoapHeader,但不仅仅是) - 当将访问权限更改为内部时,我得到了一个错误 ;当尝试创建Web代理的实例时,方法XXX无法反映

...


所以问题是:

a)我在哪里可以找到一些信息在代理类生命周期中用什么来完成.NET框架

b)还有其他任何方法(最好是自动的) ...)从代理类中尽可能多地隐藏

信息?
I''m to deploy a .NET DLL which internally communicates with the WS. I
don''t want others to see internal complexity of the web service
classes generated by "Add a Web reference" VS option.
As a WebSerive contains a lot of methods and different types creating
a web proxy class manually is too time consuming.

I tried to edit a class manually, changing the highest-level access
modifiers from public to internal - this way I could use the classes
from within the DLL, exposing only my API. However, this does not work
correctly - "some" of the classes have to be public (e.g. a class
defined as a SoapHeader, but not only) - when changing the access
modifier to internal, I got an error "Method XXX can not be reflected"
when trying to create an instance of the web proxy...

So the question is:
a) where could I find some information what is exactly done by
hte .NET framework during a proxy class lifetime
b) is there any other method (preferably automatic...) to hide as much
information as possible from the proxy class?



是的。您应该编写第二个Web服务,它抽象第一个。

的第二项服务应该尽量不那么精细。也就是说,它应该使用一个

SOA比喻。然后你应该公开第二项服务。

-

John Saunders [MVP]


P.S.当然,替代方案是以这种方式开始编写Web服务

,但如果这不是一个选项,那么代理就可以了。服务

是修复原文而不触及代码的一种方法。

Yes. You should write a second web service which abstracts the first. The
second service should try to be less fine-grained. That is, it should use an
SOA metaphor. You should then expose the second service.
--
John Saunders [MVP]

P.S. Of course, the alternative would be to have written the web service
that way to begin with, but if that''s not an option, then a "proxy" service
is one way to fix the original without touching the code.


问题与服务器端方法无关 - 它们针对服务器方法进行了优化

网络访问。问题是客户端代理DLL将在

第三方应用程序中使用,所以我想隐藏它的方法以免

混淆了人们尝试使用Intellisense。


最简单的例子:Web服务提供可用文件列表

并允许逐个下载(例如GetFilesInfo,

GetFileByName)。我想向DLL的客户端公开的是

RefreshLocalCache方法,它将在内部调用上述

并处理错误处理等。所以 - 在这种情况下

- 我真的不希望我的Web代理类暴露出来...


正如我所说,如果有人打电话给我,没有错WS直接或从代理商获得
;但是通过暴露太多我将不得不回答有关内部(来自我的POV)方法的问题

使用 - 谁读取文档?开发人员使用Intellisense ....

(这是另一个反对 - 网络代理方法没有任何

文档默认情况下)


谢谢

The question is not about server-side methods - they are optimised for
web access. The problem is that a client proxy DLL is to be used in
third-party application, so I''d like to hide its methods to not
confuse people when they try to use Intellisense.

The simpliest example: the web service gives a list of available files
and allows to download them one by one (e.g. GetFilesInfo,
GetFileByName). What I want to expose to DLL''s clients is
RefreshLocalCache method, which will internally call the
aforementioned and take care of error handling etc. So - in this case
- I really don''t want my Web Proxy class to be exposed...

As I said, nothing wrong WILL happen if somebody calls the WS either
directly or from the proxy; but by exposing too much I''ll have to
respond to questions concerning the internal (from my POV) method
usage - who reads the documentation? developers use Intellisense....
(that''s another argument against - web proxy methods don''t have any
documentation by default)

Thanks


(对不起,如果已发布类似消息,但我没看到它

自3月前发布成功以来的列表...)

Web服务API是最小的,没有任何重构。我想要的是使用我的DLL(而不是WS)隐藏代理的复杂性来自第三方
应用程序。

示例:我正在使用方法UpdateLocalCache()公开.NET DLL;它从
透明地从代理中调用一些方法:

GetFileList()x1

GetFileByName()x N

在这个例子中,我不希望DLL的用户看到GetFilexxx方法

(以及所有代理附加细节,例如超时,凭证等)。


不要误会我的意思 - 我知道WS方法可以直接使用来自用户生成的代理的
或者来自网络浏览器...我只是不是

想要回答问题/问题,例如我该如何调用

方法.... - 这将会出现,因为开发人员倾向于使用

Intellisense而不用担心文档(顺便说一句,另一个问题是使用代理类的
- 默认情况下没有记录...)。


谢谢

(sorry if the similar message is already posted, but I don''t see it on
the list since "successful" posting 3 hours ago...)

Web Service API is a minimal one, there is nothing to refactor. What I
want is to hide complexities of the proxy from third-party
applications using my DLL (not a WS).
Example: I''m exposing a .NET DLL with method UpdateLocalCache(); it
transparently call some methods from the proxy:
GetFileList() x1
GetFileByName() x N
In this example I don''t want the DLL''s users to see GetFilexxx methods
(and all proxy additional details, e.g. timeouts, credentails etc.).

Don''t get me wrong - I know the WS methods can be used either directly
from user generated proxies or from the web browser... I just don''t
want to answer questions/problems like "how should I call the
method...." - and this will come, as developers tend to use
Intellisense withour bothering about documentation (btw, another issue
with the proxy class - it''s not documented by default...).

Thanks


这篇关于封装webservice代理以隐藏复杂性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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