如何在不添加引用的情况下从客户端应用程序调用Web服务? [英] How can we call a webservice from a client application without adding reference ?

查看:71
本文介绍了如何在不添加引用的情况下从客户端应用程序调用Web服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只知道serveice网址和方法名称。

url: - http:// localhost:51507 / Service.svc

name:GetMessage();



我尝试了什么:



而不在客户端添加服务参考application

解决方案

也许这会让你入门:

如何:创建Windows Communication Foundation客户端 [ ^ ]

Web服务 - 在客户端应用程序中创建WCF端点配置,代码? - Stack Overflow [< a href =https://stackoverflow.com/questions/5098672/create-wcf-endpoint-configurations-in-the-client-app-in-codetarget =_ blanktitle =New Window> ^ ]

如何在不设计服务参考的情况下调用服务时间 [ ^ ]



我认为服务模型元数据实用工具( SvcUtil.exe )应该能够为客户端使用生成配置文件。


当WCF服务通过基本HTTP绑定公开HTTP端点时,它遵循作为SOAP Web服务的传统SOAP约定,并将SOAP信封作为HTTP请求有效负载排除。如果您不想预先创建客户端代理并仍想调用请求,则需要以编程方式创建SOAP信封并使用任何HTTP客户端(例如System.Net.WebClient)调用HTTP请求。 BLOCKQUOTE>

I just know the serveice url and method name.
url:- http://localhost:51507/Service.svc"
name : GetMessage();

What I have tried:

without adding service reference in client application

解决方案

Maybe this will get you started:
How to: Create a Windows Communication Foundation Client[^]
web services - Create WCF endpoint configurations in the client app, in code? - Stack Overflow[^]
How to call a service without adding service reference at design time[^]

I think the Service Model Metadata Utility Tool (SvcUtil.exe) should be able to generate a configuration file for client use.


When a WCF service exposes HTTP endpoints through basic HTTP bindings, it follows the classical SOAP convention of being SOAP web service, and excepts a SOAP envelope as HTTP request payload. If you don't want to pre-create client proxies and still want to invoke the request, you need to programmatically create the SOAP envelope and invoke an HTTP request using any of the HTTP client(e.g. System.Net.WebClient).


这篇关于如何在不添加引用的情况下从客户端应用程序调用Web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆