.Net Compact Framework 调用 Java WebService

 

AuthorQuietwalk

Date2010-9-27

 

.Net Compact Framework 调用 Java WebService ,与访问 IIS中的没什么区别,引用方法也相同,只是需要注意,默认端口 8080也被封了,需要换成其它的端口就可以了。记得以前在.Net 下时被 80 端口阻挡了有一两天的样子,愣是不知道问题出在哪儿,还以为是WS发布出错,一直找IIS的配置问题,不过也好,IIS配置也被我折腾熟了,呵呵,废话少说,上代码以备忘。

 

    

关键代码如下:

using GPRSTest.CommonFunctionService;//.net webservice  http://固定IP:87/CommonFunctionService/Service.asmx

 

using GPRSTest.jwsHelloWorld;//java webservice  http://固定IP:8087/ws/wsjdWebService/HelloWorld?wsdl

 

//PDA调用.Net Webservice

  private void btnResult_Click(object sender, EventArgs e)

        {

            this.btnResult.BackColor = Color.Yellow;

 

            int a = Convert.ToInt16(this.tbA.Text.Trim());

            int b = Convert.ToInt16(this.tbB.Text.Trim());

 

            DateTime dtStart = DateTime.Now;

 

            CommonFunctionService.Service cs = new Service();

 

            int iResult = cs.intAdd(a, b);

 

            this.lbHelloWorld.Text = cs.HelloWorld();

 

            DateTime dtEnd = DateTime.Now;

 

            this.lbInfo.Text ="所用时间:  "+QuietwalkClassLibrary.CommonFunctions.GetTimeSpan(dtStart, dtEnd).ToString()+"";

 

 

            this.tbResult.Text = iResult.ToString();

        }

 

//PDA调用Java Webservice

private void btnJavaWS_Click(object sender, EventArgs e)

        {

            this.btnJavaWS.BackColor = Color.Yellow;

            DateTime dtStart = DateTime.Now;

 

            jwsHelloWorld.HelloWordImplService sv = new HelloWordImplService();

 

          

            this.tbJavaResult.Text = sv.getHellWord();

 

            DateTime dtEnd = DateTime.Now;

 

            this.label4.Text = "所用时间:  " + QuietwalkClassLibrary.CommonFunctions.GetTimeSpan(dtStart, dtEnd).ToString() + "";

 

        }

 

 

原文地址:https://www.cnblogs.com/quietwalk/p/1836927.html