Web Service in Visual Studio

classic Classic list List threaded Threaded
27 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Web Service in Visual Studio

johnv
hi, has anyon on the forum got a web service working on the android using Visual Studio?
I have created a simple project, deploys fine. I added a simple web service, but it bombs with a System.Net.WebException when trying to invoke the method (in the generated Reference.cs file)
Ther web service works fine in an ordinary ASP.NET c# project
Any help would be appreciated, if I can't get this running I will not be able to use Mono for my development
thanks
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

Karl Heinz Brehme Arredondo
I tested on a proof of concept copying a MonoTouch project to Mono Android, last year, and all was OK. The webservices client code (Reference.cs for each of 3 different webservices) was COPIED from visual studio 2008… generated on a windows mobile netcf 2.0 project, since MonoTouch version, based on silverlight, do not return a DataTable, and the netcf2 projectreceives datatables and had the appropriated code.

But… that was on MonoDevelop/Mac not on Visual Studio.

Karl

From: johnv <[hidden email]>
Reply-To: "[hidden email]" <[hidden email]>
Date: Tue, 14 Feb 2012 08:24:51 -0800 (PST)
To: "[hidden email]" <[hidden email]>
Subject: [mono-android] Web Service in Visual Studio

hi, has anyon on the forum got a web service working on the android using
Visual Studio?
I have created a simple project, deploys fine. I added a simple web service,
but it bombs with a System.Net.WebException when trying to invoke the method
(in the generated Reference.cs file)
Ther web service works fine in an ordinary ASP.NET c# project
Any help would be appreciated, if I can't get this running I will not be
able to use Mono for my development
thanks

--
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list

UNSUBSCRIBE INFORMATION:


_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

Jonathan Pryor-2
In reply to this post by johnv
On Feb 14, 2012, at 11:24 AM, johnv wrote:
> hi, has anyon on the forum got a web service working on the android using Visual Studio?

Is this a WCF web service or a VS2008-style web service?

> I have created a simple project, deploys fine. I added a simple web service, but it bombs with a System.Net.WebException when trying to invoke the method

What's the stack trace?

Thanks,
 - Jon

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

Wally McClure
In reply to this post by johnv
Was this in the emulator or on a device?  I've got some sample code where I can call both wcf and asmx web services.  Are you trying to do something complicated with wcf?

Wally

> Date: Tue, 14 Feb 2012 08:24:51 -0800

> From: [hidden email]
> To: [hidden email]
> Subject: [mono-android] Web Service in Visual Studio
>
> hi, has anyon on the forum got a web service working on the android using
> Visual Studio?
> I have created a simple project, deploys fine. I added a simple web service,
> but it bombs with a System.Net.WebException when trying to invoke the method
> (in the generated Reference.cs file)
> Ther web service works fine in an ordinary ASP.NET c# project
> Any help would be appreciated, if I can't get this running I will not be
> able to use Mono for my development
> thanks
>
> --
> View this message in context: http://mono-for-android.1047100.n5.nabble.com/Web-Service-in-Visual-Studio-tp5482944p5482944.html
> Sent from the Mono for Android mailing list archive at Nabble.com.
> _______________________________________________
> Monodroid mailing list
> [hidden email]
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

johnv
hi Wally, just a very simple web service .. I get the same problem with wcf or asmx .. as I say, it works fine on a non android problem. This is using the emulator at the moment, I can't purchase the product until I can get a sample web service working

thanks for your time
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

johnv
In reply to this post by Jonathan Pryor-2
Jonathen, I have tried both, with the same result. It failes in the reference.cs file.
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

johnv
In reply to this post by Karl Heinz Brehme Arredondo
hi Karl, interesting, I'll try that, but it would be a bit of a pain if thie is the only way of getting a web service to work!
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

Tomasz Cielecki
As said, please provide a stack trace. Saying that it fails in the
Reference.cs file can be anything!

On Wed, Feb 15, 2012 at 9:12 AM, johnv <[hidden email]> wrote:

> hi Karl, interesting, I'll try that, but it would be a bit of a pain if thie
> is the only way of getting a web service to work!
>
> --
> View this message in context: http://mono-for-android.1047100.n5.nabble.com/Web-Service-in-Visual-Studio-tp5482944p5485202.html
> Sent from the Mono for Android mailing list archive at Nabble.com.
> _______________________________________________
> Monodroid mailing list
> [hidden email]
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid



--
Med Venlig Hilsen / With Best Regards
Tomasz Cielecki
http://ostebaronen.dk
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

johnv
stack trace:


Unhandled Exception:

System.Net.WebException:
Unhandled Exception:

System.Net.WebException:
[ERROR] FATAL UNHANDLED EXCEPTION: System.Net.WebException: Error: ConnectFailure (Connection refused) ---> System.Net.Sockets.SocketException: Connection refused
  at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00102] in /home/jon/Development/xamarin/mono/mcs/class/System/System.Net.Sockets/Socket_2_1.cs:1251
  at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) [0x00180] in /home/jon/Development/xamarin/mono/mcs/class/System/System.Net/WebConnection.cs:191
  --- End of inner exception stack trace ---
  at System.Net.HttpWebRequest.EndGetRequestStream (IAsyncResult asyncResult) [0x00043] in /home/jon/Development/xamarin/mono/mcs/class/System/System.Net/HttpWebRequest.cs:727
  at System.Net.HttpWebRequest.GetRequestStream () [0x00057] in /home/jon/Development/xamarin/mono/mcs/class/System/System.Net/HttpWebRequest.cs:745
  at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke (System.String method_name, System.Object[] parameters) [0x00069] in /home/jon/Development/xamarin/mono/mcs/class/System.Web.Services/System.Web.Services.Protocols/SoapHttpClientProtocol.cs:367
In mgmain JNI_OnLoad
The program 'Mono' has exited with code 255 (0xff).
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

Jonathan Pryor-2
On Feb 15, 2012, at 4:28 AM, johnv wrote:
> [ERROR] FATAL UNHANDLED EXCEPTION: System.Net.WebException: Error: ConnectFailure (Connection refused) ---> System.Net.Sockets.SocketException: Connection refused
>  at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP)

Thank you for the stack trace. :-)

Does your app have INTERNET permission? INTERNET permission is required in order to access any networked resources.

Alternatively, is your server behind a VPN/etc.? Is your Android device able to access your server, e.g. from the Browser app?

Thanks,
 - Jon

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

johnv
This post was updated on .
thanks for your reply. This is currently using the emulator, so I'm not sure that I can test web access?
How do I check if the App has internet permissions? (this looks like favourite!)

It is all internal at the moment, running IIS locally.
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

Jonathan Pryor-2
On Feb 15, 2012, at 8:06 AM, johnv wrote:
> thanks for your reply. This is currently using the emulator, so I'm not sure that I can test web access?

The emulator has a Browser app, which is the web browser. You can try accessing  your server from the Browser app.

> How do I check if the App has internet permissions? (this looks like favourite!)

You can check the project options dialog (though I forget where), and you can check in obj\Debug\android\AndroidManifest.xml, it would need to contain:

        <uses-permission android:name="android.permission.INTERNET" />

 - Jon

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

johnv
there was no manifest file, so I created one, and added the INTERNET permissions .. no joy, same result.
I then tried to access my service through the emulator, and got WEB Page Not Available message
The emulator will find pages on the internet
If I access my service through a browser on my PC it comes up ok
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

Monodroyd Blog

You can try the following tutorial to see how it goes:

http://monodroyd.wordpress.com/2012/01/09/using-web-services-to-build-your-own-weather-application-in-mono-for-android/



On Wed, Feb 15, 2012 at 8:52 AM, johnv <[hidden email]> wrote:

there was no manifest file, so I created one, and added the INTERNET
permissions .. no joy, same result.
I then tried to access my service through the emulator, and got WEB Page Not
Available message
The emulator will find pages on the internet
If I access my service through a browser on my PC it comes up ok


--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/Web-Service-in-Visual-Studio-tp5482944p5486095.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

johnv
thanks .. I can't see anything that I'm doing that is obviously different to the tutorial. It doesn't mention the Internet permission in the manifest file?
Is it something to do with the emulator set up, as it can't see my service?
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

Wally McClure
Does the emulator have internet access?  I find that the emulator will sometimes startup without internet access.  The shortcut key for this is f8 to toggle the access.

Wally

> Date: Wed, 15 Feb 2012 06:08:40 -0800

> From: [hidden email]
> To: [hidden email]
> Subject: Re: [mono-android] Web Service in Visual Studio
>
> thanks .. I can't see anything that I'm doing that is obviously different to
> the tutorial. It doesn't mention the Internet permission in the manifest
> file?
> Is it something to do with the emulator set up, as it can't see my service?
>
> --
> View this message in context: http://mono-for-android.1047100.n5.nabble.com/Web-Service-in-Visual-Studio-tp5482944p5486137.html
> Sent from the Mono for Android mailing list archive at Nabble.com.
> _______________________________________________
> Monodroid mailing list
> [hidden email]
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

johnv
This post was updated on .
yes it does, Wally, I can access the internet with the emulator, just not my (localhost) webservice!
very frustrating ...
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

Greg Shackles
You can't use "localhost" to access the host machine from the emulator. Try using 10.0.2.2, which routes to the host machine.

On Wed, Feb 15, 2012 at 9:34 AM, johnv <[hidden email]> wrote:
yes it does, Wally, I can access the internet with the emulator, just not my
(localhost) webserver!
very frustrating ...

--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/Web-Service-in-Visual-Studio-tp5482944p5486202.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

Brannon
In reply to this post by johnv
You created a manifest file through the project settings page? Did you look at the permissions in the Properties\AssemblyInfo.cs file first? And the error you posted looked like a bad address/port in your WCF configuration. Do you have that client configuration working from a Windows project?

On Wed, Feb 15, 2012 at 6:52 AM, johnv <[hidden email]> wrote:
there was no manifest file, so I created one, and added the INTERNET
permissions .. no joy, same result.
I then tried to access my service through the emulator, and got WEB Page Not
Available message
The emulator will find pages on the internet
If I access my service through a browser on my PC it comes up ok


_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
Reply | Threaded
Open this post in threaded view
|

Re: Web Service in Visual Studio

Wally McClure
In reply to this post by Greg Shackles
Was just about to suggest that. Smile The android emulator has the special 10.0.2.2 ip address for accessing on the local machine.  The other thing that you can do is to access the ip address of the local machine, but not use the localhost/127.0.0.1 ip address.

Wally


Date: Wed, 15 Feb 2012 09:48:02 -0500
From: [hidden email]
To: [hidden email]
Subject: Re: [mono-android] Web Service in Visual Studio

You can't use "localhost" to access the host machine from the emulator. Try using 10.0.2.2, which routes to the host machine.

On Wed, Feb 15, 2012 at 9:34 AM, johnv <[hidden email]> wrote:
yes it does, Wally, I can access the internet with the emulator, just not my
(localhost) webserver!
very frustrating ...

--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/Web-Service-in-Visual-Studio-tp5482944p5486202.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


_______________________________________________ Monodroid mailing list [hidden email] UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid

_______________________________________________
Monodroid mailing list
[hidden email]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
12