开发者

How to convert a .NET WebService-Method-Result (Soap) into its original datatype?

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 开发者_如何学JAVAnot 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜