• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 628
  • Last Modified:

.NET Web Service Expose Namespace

I'm trying to set up a VB.NET 3.5 web service project in Visual Studio. My goal is to include a namespace in this web service that I can expose to web applications that references this web service.

As you can see below, I have added the namespace "MyWebservices", but I am not able to find it after referencing the web service in a client application.


Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel

Namespace MyWebservices

 ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
 ' <System.Web.Script.Services.ScriptService()> _
 <System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
 <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
 <ToolboxItem(False)> _
 Public Class Service1
  Inherits System.Web.Services.WebService

  <WebMethod()> _
  Public Function HelloWorld() As String
   Return "Hello World"
  End Function

 End Class
End Namespace


<%@ WebService Language="VB" CodeBehind="Service1.asmx.vb" Class="WebService1.MyWebservices.Service1" %>
  • 2
1 Solution
Meir RivkinFull stack Software EngineerCommented:
In order for a Web service to be accessed from script, it must be an .asmx Web service whose Web service class is qualified with the ScriptServiceAttribute attribute.

check http://msdn.microsoft.com/en-us/library/bb398998.aspx
kikuchiyosesaAuthor Commented:
I have uncommented the ScriptService attribute, but I am still unable to use the namespace ("MyWebservices") in my referencing winform application.

Note:  I am connecting to my web service from a vb.net 3.5 winform.  I am trying to use the web service namespace in my winform app's code.  The link's tutorial does have code that shows that this can be done (e.g. "Samples.AspNet.SimpleWebService.EchoInput"), but their example calls the web service from an asp.net page.
When you reference a web service, you aren't really referencing it in the same manner that you would an assembly.  The reference does a little background magic and builds a proxy class that converts the low level http/xml stuff into high level function calls.  This proxy class will not utilize the namespaces present in the code behind of the web service.
kikuchiyosesaAuthor Commented:
Bummer!  I was hoping someone wouldn't say that...  Thanks to both of you for your help.

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now