WebService calling from Pocket PC - MSDN上的讨论

 

已答覆 WebService calling from Pocket PC

  • 2006年2月10日 22:48 shwe 使用者勳章 使用者勳章 使用者勳章 使用者勳章 使用者勳章
     
    Hi all,

    I have created a hello world web service.
    I can access using web browser like -
    http://localhost/TestWebService2/TestWebService2.asmx
    That is good.

    I created an Windows application to call that web service.
    It worked fine.
    I copied that windows application to other computer in the same network.
    That windows application worked fine in that computer.
    It could call that web service from that computer.

    I created a Pocket PC application to call that web service.
    I run that PPC application from my Pocket PC which is in the same network as my desktop computer in which Web service is running.
    I got an error.

    System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it

    at System.Net.Sockets.Socket.ConnectNoCheck()

    at System.Net.Sockets.Socket.Connect()

    at System.Net.Connection.doConnect()

    at System.Net.Connection.connect()

    at WorkItem.doWork()

    at System.Threading.Timer.ring()



    Yes. I got that error.
    So, from my pocket PC's internet explorer, I typed the address of that WebService as -

    http://MyComputerName/TestWebService2/TestWebService2.asmx

    It worked fine. I could see the Web Service.


    Did I do something wrong in my PPC application?
    I included that web service as Add Web Reference.
    And just called the function of that web service.
    And I don't see any .config file for Pocket PC applications.
    I manually added it but it didn't work.


    Any help is much appreciated.

    Shwe

解答

  • 2006年2月15日 18:38 shwe 使用者勳章 使用者勳章 使用者勳章 使用者勳章 使用者勳章
      已答覆
    Thank You Ilya Tumanov ,

     It was a Proxy authentication error.
     You answer to check Status property of that exception and Response property for diagnostics led me to the solution.
     I have solved it.

    Thanks again

所有回覆

  • 2006年2月10日 22:57 Ilya Tumanov MSFT , 版主 使用者勳章 使用者勳章 使用者勳章 使用者勳章 使用者勳章
     
  • 2006年2月13日 16:22 shwe 使用者勳章 使用者勳章 使用者勳章 使用者勳章 使用者勳章
     
    Thank you Ilya,
    But I have included the correct path as ' http://MyComputerName/TestWebService2/TestWebService2.asmx'.

    Any idea?

    Regards
    shwe
  • 2006年2月13日 17:42 Ilya Tumanov MSFT , 版主 使用者勳章 使用者勳章 使用者勳章 使用者勳章 使用者勳章
     

    With "localhost" issue corrected, c an you reach this WS from PIE on device? If you can not, you have network issue for your (or your IT department) to fix.

  • 2006年2月13日 21:44 shwe 使用者勳章 使用者勳章 使用者勳章 使用者勳章 使用者勳章
     
    Yes. I can reach to WebService using Pocket IE by direct typing as -
    http://MyHostComputerName/TestWebService2/TestWebService2.asmx


    May be there is an error or missing something in my code

    public partial class PDAWebConsumerForm : Form
    {
    HostWebService.TestWebService2 wsTestService = new HostWebService.TestWebService2();
    public PDAWebConsumerForm()
    {
    InitializeComponent();
    wsTestService.Url = "http://MyHostComputerName/TestWebService2/TestWebService2.asmx";
    }
    private void buttonRequest_Click(object sender, EventArgs e)
    {
    //Error happens here. It does not say anything except "WebException".
    textBoxResponse.Text = wsTestService.HelloWorld("From PDA");
    }
    }

    Any suggestion please..

    Shwe
  • 2006年2月13日 22:34 Ilya Tumanov MSFT , 版主 使用者勳章 使用者勳章 使用者勳章 使用者勳章 使用者勳章
     

    Looks good to me… You’re no longer getting " No connection could be made because the target machine actively refused it", right? What’s the stack trace for this exception?

     

  • 2006年2月14日 15:21 shwe 使用者勳章 使用者勳章 使用者勳章 使用者勳章 使用者勳章
     
    I am no longer getting that error.

    Stack trace is....
    at System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke()
    at PDAWebConsumer.HostWebServie.TestWebService2.HelloWorld()
    at.....

    Thanks
    shwe

  • 2006年2月14日 20:37 Ilya Tumanov MSFT , 版主 使用者勳章 使用者勳章 使用者勳章 使用者勳章 使用者勳章
     

    There's only one WebException thrown from this location and it's thrown if server returns error status. You can check Status property of that exception and Response property for diagnostics.

  • 2006年2月15日 14:08 shwe 使用者勳章 使用者勳章 使用者勳章 使用者勳章 使用者勳章
     
    Thank you Ilya,

    This is the code for Exception catching..
    -----------------------------------------
    private void buttonRequest_Click(object sender, EventArgs e)
    {
    try
    {
    textBoxResponse.Text = wsTestService.HelloWorld("From PDA");
    }
    catch (WebException ex)
    {
    textBoxResponse.Text = " WebException : " + ex.Message;
    textBoxResponse.Text +="/r/ nStackTrace = " + ex.StackTrace.ToString();
    textBoxResponse.Text += "/r/ nResponse = " + ex.Response;
    textBoxResponse.Text += "/r/ nStatus = " + ex.Status;
    }
    catch (Exception ex)
    {
    textBoxResponse.Text = ex.Message; ;
    }
    }
    ------------------------------------------
    This is the result...

    WebException : WebException

    StackTrace = at System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke()

    at PDAWebConsumer.HostWebService.TestWebService2.HelloWorld()

    at PDAWebConsumer.PDAWebConsumerForm.buttonRequest_Click()

    at System.Windows.Forms.Control.OnClick()

    at System.Windows.Forms.Button.OnClick()

    at System.Windows.Forms.ButtonBase.WnProc()

    at System.Windows.Forms.Control._InternalWnProc()

    at Microsoft.AGL.Forms.EVL.EnterMainLoop()

    at System.Windows.Forms.Application.Run()

    at PDAWebConsumer.Program.Main()

    Response = System.Net.HttpWebResponse

    Status = ProtocolError

    ------------------------

    Any Idea?

    Thanks
    shwe

  • 2006年2月15日 17:20 Ilya Tumanov MSFT , 版主 使用者勳章 使用者勳章 使用者勳章 使用者勳章 使用者勳章
     

    You server returned error message instead of XML data.

    You should now GetResponseStream() from response and print it out to figure our why server is complaining. It would be normal HTML WEB error, e.g. " 404 Page not found".

    I suspect you have security issues, though. Most likely your server is configured to serve requests from local host only and reject all others.

     

  • 2006年2月15日 18:38 shwe 使用者勳章 使用者勳章 使用者勳章 使用者勳章 使用者勳章
      已答覆
    Thank You Ilya Tumanov ,

     It was a Proxy authentication error.
     You answer to check Status property of that exception and Response property for diagnostics led me to the solution.
     I have solved it.

    Thanks again
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
该资源内项目源码是个人的课程设计、毕业设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。 该资源内项目源码是个人的课程设计,代码都测试ok,都是运行成功后才上传资源,答辩评审平均分达到96分,放心下载使用! ## 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.md文件(如有),仅供学习参考, 切勿用于商业用途。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值