473,765 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Implementing interface-based web services in .NET 2.0

I would like to create a set of web services that share a common set of types
(classes, structures, enums). I know I can create a VS 2005 web service based
on the Interface statement to contain these common types. The problem is that
I cannot determine how to create the implementation web services in a way
that I can cast the common types between proxy object parameters in a client
app. Please check the snippets of my code:

'Interface web service:
Namespace MyServices

Public Class CallContext
Public Environment As String
Public Version As String
End Class

Public Enum Environments
Dev
UAT
Prod
End Enum

<WebServiceBind ing(ConformsTo: =WsiProfiles.Ba sicProfile1_1,
Name:="IWsDocum ents", Namespace:="htt p://interfaces.MyCo rp.com/")_
Public Interface IWsDocuments
<WebMethod(), _
SoapDocumentMet hod(Binding:="I WsDocuments")_
Function ValidateConext( ByVal ThisCall As CallContext) As String
End Interface

<WebService(Nam espace:="http://interfaces.MyCo rp.com/")_
Public MustInherit Class WsDocumentsShim
Inherits System.Web.Serv ices.WebService
Implements IWsDocuments

<WebMethod()_
Public MustOverride Function ValidateConext( ByVal ThisCall As
CallContext) As String Implements IWsDocuments.Va lidateConext
End Class
End Namespace
'Sample implementation web service:
<WebService(Nam espace:="http://interfaces.MyCo rp.com/")_
<WebServiceBind ing(ConformsTo: =WsiProfiles.Ba sicProfile1_1)_
<Global.Microso ft.VisualBasic. CompilerService s.DesignerGener ated()_
Public Class Service1 '(other services: Service2, Service3, etc.)
Inherits IWsDocuments.Ws DocumentsShim

''' I use Shadows because compiler won't allow Overrides of web ref
object??
<WebMethod()_
Public Shadows Function ValidateConext( ByVal ThisCall As
IWsDocuments.Ca llContext) As String
If ThisCall.Versio n = "1.0" Then
Return "OK"
Else
Return "This version not supported"
End If
End Function

'Add implementation specific methods here:
End Class
'Client app:
Dim cnc As New Service1Proxy.S ervice1
Dim context As New Service1Proxy.C allContext
With context
.Environment = Service1Proxy.E nvironments.Dev
.Version = "1.0"
End With
txtResults.Text = cnc.ValidateCon ext(context)

Dim cnc2 As New Service2Proxy.S ervice2
'''' Invalid Cast Exception occurs below:
txtResults.Text &= vbCrLf & vbCrLf &
cnc2.ValidateCo next(DirectCast (context, CncService2Prox y.CallContext))
Sep 13 '06 #1
1 1868
Did some more research and came up with the answer. You have to fiddle with
the proxy generation for the client, there's no automatic way of doing this
in Visual Studio. Here are two article to look at:

for VS 2003:
http://msdn.microsoft.com/library/de...ce07162002.asp

for VS 2005: http://weblogs.asp.net/cweyer/archiv...11/212843.aspx
Sep 14 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2760
by: Martyn Lawson | last post by:
Hi, I am currently working as an Analyst on a .NET Web Project using ASP.NET and C#.NET. I have a couple of, at least what should be, quick questions: 1. My understanding of UML says that the Controller classe of a Sequence Diagram should be implemented as a private class within a component. However, my Programmer has said that since the ASP code lives outside the
4
2069
by: Frank J. Reashore | last post by:
Hello Everyone, I am implementing a simple interface in C# using Visual Studio .net and was quite surprised to discover that the C# compiler does NOT complain if a method on the interface is not implemented. VB.net on the other hand generates a compile error if a method is not implemented. This helps in ensuring that all interface methods are implemented.
3
8089
by: Frans Bouma | last post by:
Hi, I have a serious problem with VB.NET and a DataTable derived class and I can't figure out how to solve it. I have implemented it in C# where it works perfectly, but I can't port one statement to VB.NET and this is crucial: re-implementing ISerializable.GetObjectData() in the DataTable derived class so serializing the datatable derived class will call this method and not the DataTable version (which is private, so overriding is also...
5
1672
by: Colin McGuire | last post by:
Hi all, when I write the class below Private Class employee End Class and then add the line "Implements IVF" which is an interface I have written, the IDE modifies my code to display
0
1157
by: Yatin Bhuta | last post by:
Hi, I have an interface in vb 6.0. It has a property set member, which takes a parameter by reference. When I try to implement this interface in my vb.net project it gives me an error saying that "cannot implement property set because there is no matching property on interface". I think .NET does not allow parameter to be passed ByRef in property statements. here is my property set statement in vb 6.0 interface called IName
7
2097
by: Scott M. | last post by:
In a typical class, do I need to indicate that it implements the IDisposable interface and then create a Dispose method that implements the Dispose required by the IDisposable interface or can I just make a Sub Dispose() and the CLR will know that this is the Dispose method to call when the object falls out of scope? Thanks.
2
6790
by: larzeb | last post by:
I receive the following error from the compiler: ScheduledInfo' must implement 'Property AddrLine1() As String' for interface 'ICASSBatch'. Implementing property must have matching 'ReadOnly'/'WriteOnly' specifiers. The interface: Public Interface ICASSBatch Property AddrLine1() As String Property BarCode() As String
3
1667
by: David Veeneman | last post by:
I'm new to VB.NET, and I am translating an object model from C# to VB.NET, and I have come across an odd problem implementing an interface. The interface is a custom interface, IDrillDown, which declares one read-only property with the following VB.NET signature: Public ReadOnly Property ActiveText() As String I have declared the interface in the class declaration, like this:
0
1078
by: ZA_AJR | last post by:
Hi All I have a class (aClass, derived from aBaseClass) with implements an interface IMyInterface. aClass also has a private member of type aNotherClass which raises various events. I would like a specific method within aClass to handle the event raised by the object of type aNotherClass AS WELL as implementing the method of the interface. Unfortunately, the method I've used (outlined below) causes a compiler error. Is there anyway to...
5
3552
by: koonda | last post by:
Hi all, I am a student and I have a project due 20th of this month, I mean May 20, 2007 after 8 days. The project is about creating a Connect Four Game. I have found some code examples on the internet which helped me little bit. But there are lot of problems I am facing developing the whole game. I have drawn the Board and the two players can play. The players numbers can fill the board, but I have problem implementing the winner for the...
0
9399
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9955
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7378
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.