.net 从脚本或批处理文件调用 Web 服务
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1507090/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Calling a web service from a script or batch file
提问by John'o
We have a financial product that has built in scheduling capabilities to run over night batches. This product can also use web services to kick off each batch as required.
我们有一个内置调度功能的金融产品,可以在夜间批次运行。该产品还可以根据需要使用 Web 服务来启动每个批次。
I want to know if it is possible to call the web services from a .bat file or another type of batch/script file. If this is possible then we can call the batch file from the companies scheduling service (Autosys).
我想知道是否可以从 .bat 文件或其他类型的批处理/脚本文件调用 Web 服务。如果这是可能的,那么我们可以从公司调度服务 (Autosys) 调用批处理文件。
I don't want to write a exe to call this if possible (circumstances outside my control).
如果可能的话,我不想写一个 exe 来调用它(我无法控制的情况)。
KISS approach :)
亲吻方法:)
回答by Sean M
This is a take on John'o's answer that uses Microsoft.XmlHttp (which should already exist on the server\workstation)
这是对使用 Microsoft.XmlHttp 的 John'o 的回答(它应该已经存在于服务器\工作站上)
Create a .vbs a
创建一个 .vbs
Set http = CreateObject("Microsoft.XmlHttp")
http.open "GET", "http://www.webservicex.net/stockquote.asmx?WSDL", FALSE
http.send ""
WScript.Echo http.responseText
回答by John'o
Hi All I found the answer if anyone else is looking to do the same thing. The following link has an example using a .vb script to call the WS.
大家好,如果其他人想做同样的事情,我找到了答案。以下链接有一个使用 .vb 脚本调用 WS 的示例。
回答by Andrew Keith
KISS Approach
亲吻方法
in your bat file
在你的 bat 文件中
iexplore.exe <url to webpage that consumes the webservice>
would that work ?
那行得通吗?
回答by John Saunders
IMHO, KISS demands that you not use a scripting language that has no built-in web service support. Anything you do in that language will complicate things just to provide the missing capability.
恕我直言,KISS 要求您不要使用没有内置 Web 服务支持的脚本语言。你用那种语言做的任何事情都会使事情复杂化,只是为了提供缺失的功能。
KISS says create a console application in Visual Studio, add a Service Reference, call the necessary method, then run the console application in your .bat file. .bat files have built-in support for running console applications.
KISS 说在 Visual Studio 中创建一个控制台应用程序,添加一个服务引用,调用必要的方法,然后在 .bat 文件中运行控制台应用程序。.bat 文件内置支持运行控制台应用程序。

