简体   繁体   English

从C代码调用WCF

[英]Calling WCF from C code

I am working with a native C client application (not built with Visual Studio) that needs to call a WCF service. 我正在使用需要调用WCF服务的本机C客户端应用程序(不是使用Visual Studio构建)。 I am creating the WCF service, so I have complete control of it. 我正在创建WCF服务,所以我完全控制它。

Most of the information I have found deal with calling WCF from unmanaged C++ clients. 我发现的大多数信息都涉及从非托管C ++客户端调用WCF。

Has anyone tried WWSAPI? 有没人试过WWSAPI?

I am hoping to get some direction on whether this is even possible and what technologies can be used. 我希望能够就这是否可能以及可以使用哪些技术获得一些指导。 Any help would be greatly appreciated! 任何帮助将不胜感激!

you can use gSOAP is a technology that allows you to create stubs for client and server side code from WSDLs. 您可以使用gSOAP是一种允许您从WSDL为客户端和服务器端代码创建存根的技术。 Here is step by step tuttorial and that one for windows 这里是一步一步tuttorial和一个用于Windows

WCF is very powerful and configurable and allows to use many different bindings (HTTP, Sockets, MSMQ, custom, etc.). WCF功能强大且可配置,允许使用许多不同的绑定(HTTP,套接字,MSMQ,自定义等)。 Starting from version 3.5 I belive, you can use a JSON/REST bindings and contracts. 从版本3.5开始我相信,您可以使用JSON / REST绑定和契约。 Here is an official link about this: Overview of REST in WCF , and some samples here: WCF 4 JSON REST Service and here: REST Service with WCF and JSON . 以下是关于此的官方链接: WCF中的REST概述 ,以及此处的一些示例: WCF 4 JSON REST服务和此处: 使用WCF和JSON的REST服务

Now, why REST and JSON? 现在,为什么要使用REST和JSON? because these prococols are very lightweight and do not need huge dependencies or libraries. 因为这些程序非常轻量级,不需要巨大的依赖项或库。 That was in fact the whole point of REST, as opposed to SOAP . 这实际上是REST的重点,而不是SOAP

So, with these, you only need a TCP/HTTP stack and a JSON parser on the client-side wich makes it relatively easy to program in C. Here is a link to a simple JSON library: Jansson 因此,使用这些,您只需要客户端的TCP / HTTP堆栈和JSON解析器,这使得在C中编程相对容易。这是一个简单的JSON库的链接: Jansson

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM