Unable to consume web service in VB.NET Windows app-- ASP.NET works fine!!

Unable to consume web service in VB.NET Windows app-- ASP.NET works fine!!

Post by scott.iisy » Fri, 30 Mar 2007 08:58:00


i,

I have a web service which works fine under the ASP.NET development
server (on default port 4219) and also from an ASP.NET client with a
reference to the deployed service. However, I'm unable to access the
service from a windows application. I have only used ASP.NET in the
past to consume a web service, and hope I am just doing something
stupid. I've verified the service is running under IIS and I've set
the permissions to public access. I've also tried accessing the
service through both localhost and the computer name, but get the same
"Unable to connect to the remote server" error.

An ASP.NET form with a button has the following code behind and works
fine:
Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim di As dealerInterface.DealerInterface
di = New dealerInterface.DealerInterface
Dim xn As System.Xml.XmlNode
xn = di.SendQuote("<?xml version=""1.0"" encoding=""utf-8"" ?
TextBox2.Text = xn.OuterXml()
End Sub

The *exact* same code in a VB windows app (using the same web
reference URL) gives the following exception:

System.Net.WebException was unhandled
Message="Unable to connect to the remote server"
Source="System"
StackTrace:
at System.Net.HttpWebRequest.GetRequestStream()
at
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
at
WindowsApplication1.DealerInterface.DealerInterface.SendQuote(String
strXml) in C:\IISCorp\Projects\TM Window and Door
(168)\WindowsApplication1\WindowsApplication1\Web References
\DealerInterface\Reference.vb:line 85
at WindowsApplication1.Form1.Button1_Click(Object sender,
EventArgs e) in C:\IISCorp\Projects\TM Window and Door
(168)\WindowsApplication1\WindowsApplication1\Form1.vb:line 8
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m,
MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext
context)
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsForms
 
 
 

Unable to consume web service in VB.NET Windows app-- ASP.NET works fine!!

Post by JM » Fri, 06 Apr 2007 11:57:26

cott, that's a tough one. However, I've seen some pretty flaky
things happen - one of which is the .Net Framework version setting in
IIS. Somehow, from time to time, something will change the framework
version in IIS for my web service to 1.1, when it should be 2.0. This
has caused the symptom that you are describing. Perhaps it's a simple
matter of changing your framework version.

On a related note:
Do you work with web services frequently? If so, do you use a utility
for testing them? I wanted to brag about a utility that I use. No
coding test harnesses to invoke your methods, analyze results, etc.
This proggie does it all, from getting data structures, results,
statistics, the whole bit.

About the utilty:

Company: DigitForge (http://www.digitforge.com)
Utility: Visual Web Service Client
Movie: http://digitforge.com/downloads/vwsoverview.wvx




On Mar 28, 6:58 pm, XXXX@XXXXX.COM wrote: