WCF - Cross platform question

拈花ヽ惹草 提交于 2019-12-24 08:47:20

问题


I have a simple WCF service, self hosting and a .net client. I am generating a proxy using svcutil. When I add the proxy to the client it asks me to add System.ServiceModel.dll. Well, I can add it since it is a test scenario and I am working in .Net platform.

However, suppose I am using a machine that does not support .Net, how that platform would compensate for the System.ServiceModel?

Could you please put some light on it?

EDIT: I got somewhat an idea. If I am creating WCF client I need to add ServiceModel. To Test it I added a ASMX client (Add Web Reference). My service mthod does not take any params. But i get an error in client asking me to enter out int Result, out bool ResultSpecified. Could you please exlain why?

EDIT: Could you please point me to an example - how and what to set true on "DataContractSerializer"

Thanks

Lijo


回答1:


Odd question. If the client isn't a .NET application, it obviously wouldn't need System.ServiceModel. Clients can be written using any other SOAP library in whatever language the application is using.




回答2:


It would compensate by throwing an exception. You need .NET framework installed to run .NET applications. For cross platform you may take a look at Mono.


Sorry I misunderstood your question. If you expose an endpoint using basicHttpBinding any client that conforms to the WS-I Basic Profile 1.1 will be able to consume the web service without problems. This is the most interoperable binding.




回答3:


What bindings do you use?!

See also Is WCF platform independent?

Web Services Protocols Interoperability Guide

WSIT For Web Services Interoperability Technologies




回答4:


I think there are two issues here:

  1. If you're self hosting a service, but you want clients not built using .NET to have access to it, then maybe you should consider hosting it within IIS instead. Alternatively, you would need to ensure that your hosting application also includes the metadata bindings (MEX) so that non .NET platforms can access the WSDL.

  2. If you're building a non .NET client, then you'd be using a set of tools or a framework for that platform instead. That being the case, you would use different tools to create a proxy for your service from the WSDL instead.

Hope that helps.




回答5:


To eliminate the need for the two out parameters that are generated in a web service proxy, use the [XmlSerializerFormat] attribute on the operation contract. After regenerating the proxy, the method signature should match your definition rather than converting your return type into a data type "Result" and a "ResultSpecified" indicating whether the return variable is present.



来源:https://stackoverflow.com/questions/2983648/wcf-cross-platform-question

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!