Reputation: 4528
I want to create a test WCF service like this: http://www.mywebsite.com/admin/Service1.svc
Namespace Admin
Public Class Service1 Implements IService1 Public Sub New() End Sub Public Function GetData(ByVal value As Integer) As String Implements ... Return String.Format("You entered: {0}", value) End Function ' deleted rest of class End Class
End Namespace
But when I try to add a service reference to Service1.svc, I get this error:
There was an error downloading
'http://localhost:51826/Service1.svc/_vti_bin/ListData.svc/$metadata'.
If I remove my "Namespace Admin" and put Service1.svc into an "Admin" folder, then it works perfectly, but I need to structure my code since this is going to be a large project.
How can I use "Namespace" without it failing?
Upvotes: 0
Views: 547
Reputation: 5885
When you create a "WCF 4.0 Service Application", it uses the Convention-over-Configuration strategy to configure your web service; One of these conventions is that the implementation of the service is placed inside the "Default Assembly Namespace". To fix this; follow these steps:
WcfService1.Admin.Service1
Upvotes: 1
Reputation: 7612
Namespaces and folders are unrelated. You can have any namespace and put the svc in any folder you desire.
VB provides an implicit root namespace which is your project's name by default. You can see it Project > Properties > Application tab.
Nevertheless, since you want to add a "Admin" namespace, now your class is under second level namespace - <yourProjectName>.Admin
.
This has to reflect in your svc file - you have to add "Admin" to the service
attribute.
Right click on your svc file in the project and choose > Show markup. Make the change to Service
attribute of the ServiceHost
tag.
<%@ ServiceHost Language="VB" Debug="true" Service="<YourProjectName>.Admin.Service1" CodeBehind="Service1.svc.vb" %>
Upvotes: 0