开发者

.NET Web Service Root Namespace

I'm trying to set up a .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.

Service1.asmx.vb

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

Service1.asmx

<%@ WebService Language="VB" CodeBehind="Service1.asmx.vb" Class="WebService1.MyWebservices.Service1" %>

Note: I have also attempted to modify the "Root Namespace" property of the web service project, but I can't get that to work for me either.


You cannot expose the .NET namespace to clients in any way. Consider that PHP, for instance, would have no idea what a .NET namespace is, and you'll realize why such a thing can't be exposed through a cross-platform technology like web services.


Use Class=MyWebServices.Webservices1.Service1, MyWebServices.Webservices1 when using a namespace.


I think the class attribute of your asmx file header is wrong. It should be MyWebservices.Service1 not WebService1.MyWebservices.Service1.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜