mono 调用windows webService
1.???????? 實(shí)現(xiàn)linux mono Develop中調(diào)用windows 中的webService
?
?
?
?
?
?
?
?
?
?
?
?
?
l?linux 與 windows 在一個(gè)局域網(wǎng)的網(wǎng)段中
l?windows 的IIs中發(fā)布webService
?
2.???????? windows 中的設(shè)置
l?webService 的代碼
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
?
namespace MonoWebService
{
??? /// <summary>
??? /// Service1 的摘要說(shuō)明
??? /// </summary>
??? [WebService(Namespace = "http://tempuri.org/")]
??? [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
??? [System.ComponentModel.ToolboxItem(false)]
??? // 若要允許使用 ASP.NET AJAX 從腳本中調(diào)用此 Web 服務(wù),請(qǐng)取消對(duì)下行的注釋。
??? // [System.Web.Script.Services.ScriptService]
??? public class Service1 : System.Web.Services.WebService
??? {
?
??????? [WebMethod]
??????? public string HelloWorld()
??????? {
??????????? string text=string.Format("Machine Name:{0} Time:{1}",this.Server.MachineName,DateTime.Now.ToString());
?
??????????? return text;
??????? }
??? }
}
?
l?發(fā)布webService
?
l?在IE中測(cè)試
?
?
l?如果本機(jī)的防火強(qiáng)開(kāi)啟,請(qǐng)關(guān)閉。如果防火墻開(kāi)啟,windows會(huì)阻止linux的訪問(wèn)
?
?
3.???????? Linux中的設(shè)置
l?Mono中的調(diào)用代碼
?
using System;
using System.Collections;
namespace WebServiceCallApp
{
???????? class MainClass
???????? {
?????????????????? public static void Main(string[] args)
?????????????????? {
??????????????????????????? //Console.WriteLine("Hello World!");?
??????????????????????????? ArrayList myList=new ArrayList();
???????????????????????????
??????????????????????????? WinService.Service1 myService=new WinService.Service1();
??????????????????????????? Console.Write(myService.HelloWorld());
??????????????????????????? Console.Read();
?????????????????? }
???????? }
}
?
l?確認(rèn)Windows 的 WebService 可訪問(wèn)
l?Mono中添加webService
???????
注意一定要加成http://10.168.14.131/Service1.asmx?wsdl
Wsdl 必須有,不然monoDevelop 找不到webService
?
?
?
?
?
l?運(yùn)行效果
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/hbb0b0/archive/2009/06/03/1495608.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的mono 调用windows webService的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 推荐一个快速反射调用的类
- 下一篇: java信息管理系统总结_java实现科