SgDotNet
Singapore Professional .NET User Group -For Cool Developers

Error: WebException was unhandled... could not establish connection to network

rated by 0 users
This post has 1 Reply | 1 Follower

Top 500 Contributor
Posts 3
Li Lien Posted: 06-04-2007 4:05 PM

Hi

I have created a web service with a simple method that returns "Hello World". The web service works when tested. However, when it is consumed by my smart device application, I get the error "WebException was unhandled, Could not establish connection to network". What is the cause and how do i resolve?

Here's my code

**************************************************************************************************************************************

Form calling web service method "localhost.Service.HelloWorld()"

**************************************************************************************************************************************

Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click

Dim MyService As localhost.Service = New localhost.Service()

Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click

Dim MyService As localhost.Service = New localhost.Service()

Dim MyService As localhost.Service = New localhost.Service()

 

MsgBox(MyService.HelloWorld())

End Sub

End Sub

**********************************************************************************************************************************************

Error occus at line underlined and italicised

**********************************************************************************************************************************************

'------------------------------------------------------------------------------

' <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>

'------------------------------------------------------------------------------

Option Strict Off

Option Explicit On

Imports System

Strict Off

Option Explicit On

Imports System

Explicit On

Imports System

System

Imports System.ComponentModel

System.ComponentModel

Imports System.Data

System.Data

Imports System.Diagnostics

System.Diagnostics

Imports System.Web.Services

System.Web.Services

Imports System.Web.Services.Protocols

System.Web.Services.Protocols

Imports System.Xml.Serialization

System.Xml.Serialization

'

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

'

Namespace localhost

 

'''<remarks/>

localhost

 

'''<remarks/>

'''<remarks/>

<System.Diagnostics.DebuggerStepThroughAttribute(), _

System.ComponentModel.DesignerCategoryAttribute("code"), _

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

Partial Public Class Service

Inherits System.Web.Services.Protocols.SoapHttpClientProtocol

 

'''<remarks/>

"code"), _

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

Partial Public Class Service

Inherits System.Web.Services.Protocols.SoapHttpClientProtocol

 

'''<remarks/>

"ServiceSoap", [Namespace]:="http://tempuri.org/")> _

Partial Public Class Service

Inherits System.Web.Services.Protocols.SoapHttpClientProtocol

 

'''<remarks/>

Partial Public Class Service

Inherits System.Web.Services.Protocols.SoapHttpClientProtocol

 

'''<remarks/>

Inherits System.Web.Services.Protocols.SoapHttpClientProtocol

 

'''<remarks/>

'''<remarks/>

Public Sub New()

MyBase.New

Me.Url = "http://localhost/WSUpdateData/Service.asmx"

Public Sub New()

MyBase.New

Me.Url = "http://localhost/WSUpdateData/Service.asmx"

MyBase.New

Me.Url = "http://localhost/WSUpdateData/Service.asmx"

Me.Url = "http://localhost/WSUpdateData/Service.asmx"

End Sub

End Sub

 

'''<remarks/>

'''<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 Function HelloWorld() As String

"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 Function HelloWorld() As String

Public Function HelloWorld() As String

Dim results() As Object = Me.Invoke("HelloWorld", New Object(-1) {})  <<<<< ERROR OCCUR AT THIS LINE

Return CType(results(0),String)

End Function

Dim results() As Object = Me.Invoke("HelloWorld", New Object(-1) {})  <<<<< ERROR OCCUR AT THIS LINE

Return CType(results(0),String)

End Function

Return CType(results(0),String)

End Function

End Function

 

'''<remarks/>

'''<remarks/>

Public Function BeginHelloWorld(ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult

Return Me.BeginInvoke("HelloWorld", New Object(-1) {}, callback, asyncState)

End Function

Public Function BeginHelloWorld(ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult

Return Me.BeginInvoke("HelloWorld", New Object(-1) {}, callback, asyncState)

End Function

Return Me.BeginInvoke("HelloWorld", New Object(-1) {}, callback, asyncState)

End Function

End Function

 

'''<remarks/>

'''<remarks/>

Public Function EndHelloWorld(ByVal asyncResult As System.IAsyncResult) As String

Public Function EndHelloWorld(ByVal asyncResult As System.IAsyncResult) As String

Dim results() As Object = Me.EndInvoke(asyncResult)

Return CType(results(0),String)

End Function

Dim results() As Object = Me.EndInvoke(asyncResult)

Return CType(results(0),String)

End Function

Return CType(results(0),String)

End Function

End Function

 

 

 

End Class

 

End Namespace

Namespace

 

 

Top 10 Contributor
Posts 2,284
Smart device = remote device? Has your web service/web server and firewall been configured to allow connections from remote computers?

The melody of logic will always play out the truth. ~ Narumi Ayumu, Spiral

Page 1 of 1 (2 items) | RSS
Copyright SgDotNet 2004-2008
Powered by Community Server (Commercial Edition), by Telligent Systems