创建Web服务和客户端共享类型 [英] Creating web service and client with shared types

查看:238
本文介绍了创建Web服务和客户端共享类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已创建了从XSD架构文件共享导入类型两个WSDL文件。

I have created two wsdl files with shared types imported from xsd schema file.

之后,我已经采用以参数Wsdl.exe用工具生成的界面创建Web服务/ serverInterface。

After that I have created web services using interface generated by wsdl.exe tool with parameter /serverInterface.

弗里斯特Web服务,具有Web方法RegisterData与进入队列一些复杂的物体通过系统A进行处理。由于该方法返回布尔结果(有告诉我们,物体的登记成功)。

Frist web service, have web method "RegisterData" with put into queue some complex object to be processed, by system "A". As result of this method is returned Boolean (with tell us that object was registered successful).

二Web服务,有网络法的UpdateData更新系统中的一些数据b基于同样的对象,与系统A的过程改变了。

Second web service, have web method "UpdateData" to update some data in system "B" based on this same object , with was changed in process on system "A".

因此,在系统中的A我要创建的第二个Web服务客户端,在那里我会打电话给法的UpdateData这一修正的复杂对象我们的说法。

So in system "A" I have to create client for second web service, where I will call method "UpdateData" with this modified complex object us argument.

但是当我创建这个客户端在Visual Studio(通过添加Web引用或添加服务引用)我要创造一些空间的客户端。然后,当我试图调用的UpdateDataagument必须从第一个Web服务RegisterData的方法收到此相同的对象不同的命名空间。

But when I’m creating this client in Visual Studio (by add web reference or add service reference) I have to create some namespace for client. And then when I’m trying to call "UpdateData" agument have different namespace for this same object received from first web service "RegisterData" method.

我想创建第一个Web服务和第二Web服务客户端,在那里我可以用它们之间的相同类型的对象。

I would like to create first web service and second web service client , where I can use this same type object between them.

非常感谢你的帮助。

推荐答案

我不相信这是可能的ASMX Web服务。

I don't believe this is possible with ASMX web services.

WCF不然而支持这项工作,。

WCF does support this, however.

WCF链接

  • WCF Developer Center
  • Beginner's Guide to Windows Communication Foundation
  • How to: Configure a Service to Reuse Existing Types

其实,我觉得我可能会误解你的问题。我虽然你试图在客户端和服务器之间共享相同的类型。 ASMX不能做到这一点。然而,似乎您试图共享两个客户端之间的代理同一类型。您可以轻松地使用Wsdl.exe工具做到这一点。

Actually, I think I may have misread your question. I though you were trying to share the same types between the client and the server. ASMX cannot do that. However, it appears you are trying to share the same types between two client proxies. You can do that easily using the WSDL.EXE tool.

考虑一个方案,DataTypes.xsd和两个WSDL文件导入,ServiceA.wsdl和ServiceB.wsdl 。要创建服务器接口,使用:

Consider a schema, DataTypes.xsd, and two WSDL files that import it, ServiceA.wsdl and ServiceB.wsdl. To create the server interfaces, use:

WSDL / serverInterface /n:SharedTypes.Servers /out:Services.cs ServiceA.wsdl ServiceB。 WSDL DataTypes.xsd

wsdl /serverInterface /n:SharedTypes.Servers /out:Services.cs ServiceA.wsdl ServiceB.wsdl DataTypes.xsd

这将创建一个可以以创建服务实现接口。这些接口都将使用一套由DataTypes.xsd创建的类。要创建代理类,只需使用:

This will create interfaces which you can implement in order to create your services. These interfaces will both use one set of classes created from DataTypes.xsd. To create the proxy classes, simply use:

WSDL /n:SharedTypes.Proxies /out:Proxies.cs ServiceA.wsdl ServiceB.wsdl DataTypes.xsd

wsdl /n:SharedTypes.Proxies /out:Proxies.cs ServiceA.wsdl ServiceB.wsdl DataTypes.xsd

注意,您不需要 / sharedTypes 开关。具有不同的目的。这是因为当你需要下载WSDL和从服务的XSD结合类型的外部服务。

Notice that you do not need the /sharedTypes switch. That has a different purpose. It is for combining types of external services when you need to download the WSDL and any XSD from the service.

我已经试过这一点使用像你这样的一个例子,ServiceA张贴消息放入队列中,和客户端拾起该消息并把它发送到ServiceB。它的工作原理相当不错的。

I have tried this using an example like yours, ServiceA posting a message into a queue, and a client picking up that message and sending it to ServiceB. It works quite well.

这篇关于创建Web服务和客户端共享类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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