开发者

Passing Objects Between WCFs

I have an ASP application, which calls an HTTP WCF service, which calls a TCP WCF service (all on different servers). I'm ultimately trying to pass one class object between the three.

I've discovered that I can't do this directly in the HTTP WCF, even though my class object is defined identically in BOTH WCFs. Like this:

Public Function CallOtherFunction(ByVal ThisClass as MyClass)
Dim RetVal as Boolean

     RetVal = CallMyOtherWCFFunction(ThisClass)
开发者_开发知识库
End Function

Instead I have to:

Public Function CallOtherFunction(ByVal ThisClass as MyClass)

Dim RetVal as Boolean
Dim MyOutgoingClass as MyOtherWCF.MyClass

     MyOutgoingClass.MyString = ThisClass.MyString
     RetVal = CallMyOtherWCFFunction(MyOutgoingClass)

End Function

My objects are rather large, to say they have a lot of properties. Any way to not have to declare a new variable in my calling function, so my code can be a little easier (like the first example)?

Thanks, Jason


You can't pass it directly because those are two diffrent types. You can, however, declare your data contracts in a shared assembly (used by the three projects, or at least by the HTTP and the TCP services), an when adding the service reference to create the proxy in the HTTP service, you specify that you want to "reuse types in referenced assemblies". This way it should use the same type in all projects.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜