如何将一个.NET的WebService - 方法 - 结果(SOAP)其原始数据类型? [英] How to convert a .NET WebService-Method-Result (Soap) into its original datatype?
问题描述
我有两个不同的服务器上的两个相同的Web服务(SOAP)。不要问为什么: - )
的WebService-1决定它是否HANDELS请求本身,或者如果它将该请求传递给WebService的-2。如果是这样,WebService的-2的反应应该直接从web服务-1返回。
的响应数据类型是复杂的和自定义的。通过简单的数据类型如int或串不会有什么问题。
WebService的-2的响应是一个序列化对象(我认为这是所谓的存根),并theredore它不possibel通过通过这个对象的WebService-1的响应,因为对象的类型不匹配。
有没有为序列化的数据类型转换成原来的类型,除非层楼高复杂的转换器一个简单的方法?
是 - 如何实现这一目标不同,取决于您是否使用WCF或旧样式的Web服务
从本质上讲,你要在网上参考工具(svcutil.exe的或Wsdl.exe用,分别),以确定该web服务的结果居然是一个知名的对象类型 - 就像它为许多核心框架对象。
在WCF,这通常是通过确保您的合同中引用的程序集举行实现,并装饰有名称空间的属性。如果你这样做,当你添加一个引用到你的Web服务应使用产生类似的代理类的类本身来代替。
如果您使用的是旧式的网络服务,你将不得不考虑使用一个SchemaImporter项目 - 这将使Wsdl.exe工具来识别你的类型和正确利用它们。应该提到的,这仅需要在设计时 - 在部署过程中,无需这样的措施</ P>
I have two "identical" webservices (Soap) on two different servers. Don't ask why :-)
WebService-1 decides if it handels the request itself or if it passes the request to WebService-2. If so, the response of WebService-2 should directly be returned from WebService-1.
The response datatype is complex and self defined. With simple datatypes like 'int or 'string' there would be no problem.
The response of WebService-2 is a serialized object (I think it is called "stubs") and theredore it is not possibel to pass this object through as the response of WebService-1 because the type of the objects doesn't match.
Is there a simple way to convert the serialised datatype into its original type without buiding a complex converter?
Yes - how to achieve this differs depending on whether you are using WCF or old-style Web Services.
Essentially, you want the web reference tools (svcutil.exe or wsdl.exe, respectively) to identify that the result of the webservice is actually a "well-known" object type - much as it does for many of the core framework objects.
Within WCF, this is normally achieved by ensuring that your contracts are held in a referenced assembly, and are decorated with namespace attributes. If you do this, when you add a reference to your webservice it should use your class natively instead of generating a similar proxy class.
If you are using old-style web-services, you will have to look into using a SchemaImporter project - this will allow the wsdl.exe tool to recognise your types and correctly utilise them. It should be mentioned that this is only required at design-time - no such measures are required during deployment.
这篇关于如何将一个.NET的WebService - 方法 - 结果(SOAP)其原始数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!