J
Jeff Johnson
Disclaimer: I am extremely new to Web services and may very well be doing
the wrong thing!
Background: I have a Web service and a Windows Forms client app (VS 2005).
The Web service exposes a method to accept a ScheduleEntry object, which is
a class I have written. I felt doing this would be cleaner than passing 7 or
8 parameters, but I've run into some problems.
First, I learned that declaring classes in Web services isn't such a great
idea because the proxy class you get in your client app when you make a Web
reference only has properties and not methods.
So I decided that I'd move my class definition to a separate assembly that
I'd then reference in both the Web service and my app. This sort of works,
but now I'm getting a separate definition of the class through the Web
service. This is hard to explain so I'll give an example.
---------------
1. Assembly which contains my class (we'll call it "Scheduling.dll.")
namespace Main.Name.Space
{
public class ScheduleEntry
{
// Stuff
}
}
---------------
---------------
2. Web service
[WebService(Namespace = http://www.mycompany.com/schedulerservice)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class SchedulerService : System.Web.Services.WebService
{
[WebMethod]
public int AddScheduleEntry(ScheduleEntry schedule)
{
// Stuff
}
}
---------------
---------------
3. Client app
This app contains a Web reference which I named "Scheduler" and a regular
reference to Scheduling.dll. It uses the same namespace as Scheduling.dll
(i.e., Main.Name.Space). I can see that this namespace contains a class
known as Main.Name.Space.ScheduleEntry. However, when I create an instance
of Scheduler.ScheduleService and look at the signature of the
AddScheduleEntry() method, the parameter is identified as
Main.Name.Space.Scheduler.ScheduleEntry and I can't pass a
Main.Name.Space.ScheduleEntry object because the compiler complains that it
can't cast between those types.
Is there any kind of decoration I need to do in the Web service so that when
the WSDL is interrogated and the proxy built in my client the ScheduleEntry
class comes out with the proper namespace?
the wrong thing!
Background: I have a Web service and a Windows Forms client app (VS 2005).
The Web service exposes a method to accept a ScheduleEntry object, which is
a class I have written. I felt doing this would be cleaner than passing 7 or
8 parameters, but I've run into some problems.
First, I learned that declaring classes in Web services isn't such a great
idea because the proxy class you get in your client app when you make a Web
reference only has properties and not methods.
So I decided that I'd move my class definition to a separate assembly that
I'd then reference in both the Web service and my app. This sort of works,
but now I'm getting a separate definition of the class through the Web
service. This is hard to explain so I'll give an example.
---------------
1. Assembly which contains my class (we'll call it "Scheduling.dll.")
namespace Main.Name.Space
{
public class ScheduleEntry
{
// Stuff
}
}
---------------
---------------
2. Web service
[WebService(Namespace = http://www.mycompany.com/schedulerservice)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class SchedulerService : System.Web.Services.WebService
{
[WebMethod]
public int AddScheduleEntry(ScheduleEntry schedule)
{
// Stuff
}
}
---------------
---------------
3. Client app
This app contains a Web reference which I named "Scheduler" and a regular
reference to Scheduling.dll. It uses the same namespace as Scheduling.dll
(i.e., Main.Name.Space). I can see that this namespace contains a class
known as Main.Name.Space.ScheduleEntry. However, when I create an instance
of Scheduler.ScheduleService and look at the signature of the
AddScheduleEntry() method, the parameter is identified as
Main.Name.Space.Scheduler.ScheduleEntry and I can't pass a
Main.Name.Space.ScheduleEntry object because the compiler complains that it
can't cast between those types.
Is there any kind of decoration I need to do in the Web service so that when
the WSDL is interrogated and the proxy built in my client the ScheduleEntry
class comes out with the proper namespace?