如何使用visual studio 2013将我的控制台应用程序转换为Web服务 [英] How can I convert my console application to a web service using visual studio 2013

查看:100
本文介绍了如何使用visual studio 2013将我的控制台应用程序转换为Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个控制台应用程序,它使用Web服务并在响应中使用json字段,该字段具有下载文档的链接。使用altchunk将此文档的内容添加到另一个文档中。现在我如何将此应用程序公开为服务。任何有关这方面的帮助都会有所帮助。



我尝试过:



namespace CallingWebService

{

class program

{

static void Main(string [] args)

{

var webRequest = WebRequest.Create(url);



using(var response = webRequest .GetResponse())

使用(var content = response.GetResponseStream())

使用(var reader = new StreamReader(content))

{

var strContent = reader.ReadToEnd();

var objects = JArray.Parse(strContent); //解析为数组

foreach(对象中的JObject root)

{

foreach(KeyValuePair

i have a console application that consumes a web service and uses a json field in the response that has a link to download a document. Content of this doc is added to another document using altchunk. Now how can i expose this application as a service. Any help on this would be helpful.

What I have tried:

namespace CallingWebService
{
class Program
{
static void Main(string[] args)
{
var webRequest = WebRequest.Create("url");

using (var response = webRequest.GetResponse())
using (var content = response.GetResponseStream())
using (var reader = new StreamReader(content))
{
var strContent = reader.ReadToEnd();
var objects = JArray.Parse(strContent); // parse as array
foreach (JObject root in objects)
{
foreach (KeyValuePair

推荐答案

你基本上要问的是我如何编写一个网站?这个问题在一个快速回答论坛中的范围太广了。学习webforms或MVC以及如何做到这一点将成为显然。



请注意,您的控制台应用程序可以执行网站\ web服务无法执行的操作,因为它在本地计算机上运行而Web服务不是,所以你将无法将文件保存到客户端文件系统,在客户端文件系统上运行文件等等,所以如果这是你的目标,我马上就会放弃。
What you're basically asking is "How do I write a website?" and that is far too broad a topic to cover in a Quick Answer forum. Learn webforms or MVC and how to do this will become apparent.

Note however that your console app can do things a website\webservice can't as it is running on the local machine and the webservice isn't, so you won't be able to save files to the client file system, run files on the client file system etc so if that is your aim I'd give up right away.


这篇关于如何使用visual studio 2013将我的控制台应用程序转换为Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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