cannot establish network connection

Good Morning,

I have written a very simple web service and I cannot connect to it. However, I can connect to it via the brower and from the Reference.cs of the project.  Yes it does what it is supposed to: Add two numbers.

I added the web refernce the same way I would if the was a asp.net application.

Right clicking References then Add New Web Reference.

Below works fine from Reference.cs

public MathService() {this.Url = http://172.17.110.122/MathService/MathService.asmx;}

This does not work fine from Application:

using Math.WebReference;

MathService myMath = new MathService();

private void button1_Click(object sender, EventArgs e)

{

label3.Text = "result = " + myMath.Add(operand1, operand2).ToString();

}

The Web Service was written using VS 2003 - CS

The Application was written using VS2005 - cs smart devices

Here are the DETAILS of the error message from the Emulator.

Could Not Establish connection to network.

at
System.Net.HttpWebRequest.finishGetResponse()
at
System.Net.HttpWebRequest.GetResponse()
at
System.web.Services.Protocols.HttpWebClientProtocol.GetWebResponse()
at
System.web.Services.Protocols.HttpWebClientProtocol.GetWebResponse()
at

 this message goes on....if i need to post more of the error message please let me know.

Thanks in advance




Answer this question

cannot establish network connection

  • Kripz

    Alrighty, it works for me. The procedure (for VS 2005 & Windows Mobile 5.0 Pocket PC Emulator) below helped me to resolve this exception:

    1. Run your emulator first (make sure that your emulator doesn't attempt to access any web service; meaning don't hit any command buttons on emulator that will try to connect to web service in question)

    2. Select Device-Emulator-Manager from Tools Menu.

    3. Look for the emulator (that you ran in Step 1) in this list. There should be a green, play-button kinda icon next to that emulator's name. Refresh this list if you don't see the icon.

    4. Now run Microsoft ActiveSync.

    5. Go back to Device-Emulator-Manager (that you opened in step 2). Right click on the emulator with green icon and select CRADLE.

    6. Go to Microsoft ActiveSync. A Pocket-PC-Sync-Setup wizard should pop-up.

    7. Click Next. Unselect all options. Click Next. Click Finish.

    8. Now, you should see CONNECTED status in Microsoft ActiveSync window.

    9. You are good to play with your emulator now. The emulator is ready to fetch data using web services.

    Hope that helps,

    Sumant


  • bucketofsquid

    Dan,

    Followed the NETWORK connection suggestion.

    I have one choice called: Enable NE2000 PCMIA network adapter and bind to:

    I also have a check box that allows me to: Host Only Networking.

    Neither worked. The NE2000 failed since I do not have one.

    And the second property made no difference unfortunatly.

    I am so close to tossing the machines out the window. Ah good times.

    If you have any other suggestions please let me know or feel free to drop by:)

    Jesse



  • Jeroen Vos

    Sorry I forgot to answer your other enquiries.

    The device is on its way from michigan to toronto. So I am strickly using the emulator.

    Thanks again,

    Jesse



  • Klaus Prückl

    Just a thought, do you have the network turned on for the emulator

    Emulator -> File | Configure | Network tab, check box for network checked

    Dan



  • cgn

    Hi Dan,

    Here is the file. This is from my machine at home.

    This is the really simple helloworld ws reference:

    I can get to this ws via the browser and asp.net apps. I cannot however get to the ws via an application developed with VS2005 smart devices. Here is the code.

    //------------------------------------------------------------------------------

    // <auto-generated>

    // This code was generated by a tool.

    // Runtime Version:2.0.50727.42

    //

    // Changes to this file may cause incorrect behavior and will be lost if

    // the code is regenerated.

    // </auto-generated>

    //------------------------------------------------------------------------------

    //

    // This source code was auto-generated by Microsoft.CompactFramework.Design.Data, Version 2.0.50727.42.

    //

    namespace det_ws_test.det_ws_test {

    using System.Diagnostics;

    using System.Web.Services;

    using System.ComponentModel;

    using System.Web.Services.Protocols;

    using System;

    using System.Xml.Serialization;

    /// <remarks/>

    [System.Diagnostics.DebuggerStepThroughAttribute()]

    [System.ComponentModel.DesignerCategoryAttribute("code")]

    [System.Web.Services.WebServiceBindingAttribute(Name="Service1Soap", Namespace="http://tempuri.org/")]

    public partial class Service1 : System.Web.Services.Protocols.SoapHttpClientProtocol {

    /// <remarks/>

    public Service1() {

    this.Url = "http://192.168.1.105/WebService1/Service1.asmx";

    }

    /// <remarks/>

    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/HelloWorld", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]

    public string HelloWorld() {

    object[] results = this.Invoke("HelloWorld", new object[0]);

    return ((string)(results[0]));

    }

    /// <remarks/>

    public System.IAsyncResult BeginHelloWorld(System.AsyncCallback callback, object asyncState) {

    return this.BeginInvoke("HelloWorld", new object[0], callback, asyncState);

    }

    /// <remarks/>

    public string EndHelloWorld(System.IAsyncResult asyncResult) {

    object[] results = this.EndInvoke(asyncResult);

    return ((string)(results[0]));

    }

    }

    }

    Thanks In advance.



  • Wout

    I'm having problem with emulator. I tried all I can but still couldn't make it work. The error message I got is:

    “Could not establish connection to network".

    Any help will be appreciated!

    Eva


  • Bhaskardeep Khaund

    Sumant,

    Thanks so much! I’m playing around with ActiveSync following your suggestions. It helps me to go a few steps further.

    My problem now is that Pocket-PC-Sync-Setup does not pop-up. I don’t know how to bring it up. I remembered it once popped-up.

    My ActiveSync version is 4.5. My emulator is 8.0xxx (by checking DeviceEmulator.exe file) which came with VS 2005.

    Do you have any suggestion to bring the Pocket-PC-Sync-Setup pop-up

    Eva


  • Robin Sarac

    Sumant,

    Thanks so much! I got it work.

    Eva


  • JC Carmo

    Is the emulator 'Docked' Can you browse the imternet from your device

    To get it docked, in the IDE click on the Tools menu and then click on 'Device Emulator Manager'.

    Locate your running emulator type in the dialog, select it and then on the 'Actions' menu click on 'Cradle'.

    That shou;d get your emulator connected to the network.

    Dan



  • Mark Macumber

    What would really be useful is the cs file for your refernce. Can you ping the device from the desktop Or maybe ping the webservice server from the device

    Does your PPC have an IPAddress Is the iP for the web service the same as shown earlier

    Dan



  • Z_ms

    Dan,

    I got it working...... ARG.

    I did not realize that active sync need to be in DMA mode and not in COM1, COM2, COM3.

    I changed that and I was good to go.

    Thank you for your time and good advice.

    I really appreciate it.

    Regards,

    Jesse



  • Paarul

    Hi Dan,

    Because of Proxy server and other issues I cannot surf. However the WS I am trying to connect to is:

    Is on my machine. So internal requests should be ok. Should it not

    Also I craddled the device after reading your reply. Thanks for that tip.

    Anything else you can suggest would be greatly appreciated

    Jesse



  • Will Buchanan

    If this helps - here is all the important code:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using Math.WebReference;
    using System.Net;

    namespace Math
    {
    public partial class Form1 : Form
    {
    MathService myMath = new MathService();

    public Form1()
    {
    InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
    try
    {
    float operand1 = float.Parse(textBox1.Text);
    float operand2 = float.Parse(textBox2.Text);
    label3.Text = "Add result = " + myMath.Add(operand1, operand2).ToString();
    }
    catch (System.Net.WebException ex)
    {
    label3.Text = "WebException : " + ex.Message;
    label3.Text += "\r\nStackTrace= " + ex.StackTrace.ToString();
    label3.Text += "\r\nResponse= " + ex.Response;
    label3.Text += "\r\nStatus= " + ex.Status;
    }
    catch (Exception ex)
    {
    label3.Text = ex.Message;
    }
    }



  • cannot establish network connection