472,805 Members | 942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

Creating Generic Class from 2 classes

This is a little complicated to explain but I have some web services on a
machine that work great.

The problem is that I have run into a situation where I need to set up my
program to access one or another (could also be 3) different web servers to
use these Web Services. The Web Services are identical on all the machines.
I tried just changing the URL of the Web Services and cannot make it work.
I then decided to create 2 identical web services (one for each machine) and
then use a generic type to use in my code.

The 2 web Servers are Earth and Saturn.

I originally had a Web Service called RemoteUserService, which has a method
fetchRemoteUserInfo.

To make this work I created 2 web services and called them RemoteUserEarth
and RemoteUserSaturn. Both Services are identical except for the URL they
point to and their Namespaces (ClassLibrary4.RemoteUserEarth and
ClassLibrary4.RemoteUserEarth).

I then tried all combinations of defines to make this work and kept coming
up with compiler errors - mainly "Cannot Implicitly assign" errors.

I came closest with:

ClassLibrary4.RemoteUserEarth.RemoteUserServiceSer vice
remoteUserServiceEarth = new
ClassLibrary4.RemoteUserEarth.RemoteUserServiceSer vice();

ClassLibrary4.RemoteUserSaturn.RemoteUserServiceSe rvice
remoteUserServiceSaturn = new
ClassLibrary4.RemoteUserSaturn.RemoteUserServiceSe rvice();

object remoteUserService;

remoteUserService =
(ClassLibrary4.RemoteUserSaturn.RemoteUserServiceS ervice)remoteUserServiceTfs;

This compiles fine, but I can't use the remoteUserService in my code as it
is an object.

ruDataBean = remoteUserService.fetchRemoteUserInfo(
userID,
"swpays",
"10.0.0.25",
"C", //Client (employer)
sessionID);

This gives me an error "'object' does not contain a definition for
'fetchRemoteUserInfo'".

What I am trying to do is get remoteUserService be the generic class that I
can using throughout my code. I don't want to create multiple instances of
the same code when the only difference is the machine I point to. If I then
have to set up a 3rd machine, I would have recreate all my code again for
the 3rd machine. I would much rather just set up another variable, such as
remoteUserServiceMars which I just assign to remoteUserService when I point
to that machine.

Can this be done?

Thanks,

Tom
Apr 1 '06 #1
16 2277
Tshad,

Changing URL to connect to different webservices is the best and easy way..I
do it all the time and it works great, we connect to different servers
also.. Could you post a sample of your problem in ability to connect to
different URL.

Vijay

"tshad" <ts**********@ftsolutions.com> wrote in message
news:u7**************@TK2MSFTNGP14.phx.gbl...
This is a little complicated to explain but I have some web services on a
machine that work great.

The problem is that I have run into a situation where I need to set up my
program to access one or another (could also be 3) different web servers
to use these Web Services. The Web Services are identical on all the
machines. I tried just changing the URL of the Web Services and cannot
make it work. I then decided to create 2 identical web services (one for
each machine) and then use a generic type to use in my code.

The 2 web Servers are Earth and Saturn.

I originally had a Web Service called RemoteUserService, which has a
method fetchRemoteUserInfo.

To make this work I created 2 web services and called them RemoteUserEarth
and RemoteUserSaturn. Both Services are identical except for the URL they
point to and their Namespaces (ClassLibrary4.RemoteUserEarth and
ClassLibrary4.RemoteUserEarth).

I then tried all combinations of defines to make this work and kept coming
up with compiler errors - mainly "Cannot Implicitly assign" errors.

I came closest with:

ClassLibrary4.RemoteUserEarth.RemoteUserServiceSer vice
remoteUserServiceEarth = new
ClassLibrary4.RemoteUserEarth.RemoteUserServiceSer vice();

ClassLibrary4.RemoteUserSaturn.RemoteUserServiceSe rvice
remoteUserServiceSaturn = new
ClassLibrary4.RemoteUserSaturn.RemoteUserServiceSe rvice();

object remoteUserService;

remoteUserService =
(ClassLibrary4.RemoteUserSaturn.RemoteUserServiceS ervice)remoteUserServiceTfs;

This compiles fine, but I can't use the remoteUserService in my code as it
is an object.

ruDataBean = remoteUserService.fetchRemoteUserInfo(
userID,
"swpays",
"10.0.0.25",
"C", //Client (employer)
sessionID);

This gives me an error "'object' does not contain a definition for
'fetchRemoteUserInfo'".

What I am trying to do is get remoteUserService be the generic class that
I can using throughout my code. I don't want to create multiple instances
of the same code when the only difference is the machine I point to. If I
then have to set up a 3rd machine, I would have recreate all my code again
for the 3rd machine. I would much rather just set up another variable,
such as remoteUserServiceMars which I just assign to remoteUserService
when I point to that machine.

Can this be done?

Thanks,

Tom

Apr 1 '06 #2
"Vijay" <vi***@msdiscussions.com> wrote in message
news:Oy**************@TK2MSFTNGP12.phx.gbl...
Tshad,

Changing URL to connect to different webservices is the best and easy
way..I do it all the time and it works great, we connect to different
servers also.. Could you post a sample of your problem in ability to
connect to different URL.
I tried that using the following:

remoteUserService.Url =
http://10.0.0.25:8080/data/services/RemoteUserService;

newHireService.Url = http://10.0.0.25:8080/data/services/newHireService;

employeeTaxService.Url =
http://10.0.0.25:8080/data/services/employeeTaxService;

This worked for the first one, but not the second one. These were written
in Java, and we do have a problem with creating the proxy when using
multi-dimensional strings ([][]).

I don't know if this is the case, but what I am trying to do is just create
all the web service Object and then create generic object that I change to
whichever service I need to access.

I just know how to get this to work. I thought I had it finally setting up
the generic service as an object and I seem to be able to assign the actual
service to it, but I can't seem to access the methods (and I assume the
properties).

Is there a way to make this method work?

Thanks,

Tom
Vijay

"tshad" <ts**********@ftsolutions.com> wrote in message
news:u7**************@TK2MSFTNGP14.phx.gbl...
This is a little complicated to explain but I have some web services on a
machine that work great.

The problem is that I have run into a situation where I need to set up my
program to access one or another (could also be 3) different web servers
to use these Web Services. The Web Services are identical on all the
machines. I tried just changing the URL of the Web Services and cannot
make it work. I then decided to create 2 identical web services (one for
each machine) and then use a generic type to use in my code.

The 2 web Servers are Earth and Saturn.

I originally had a Web Service called RemoteUserService, which has a
method fetchRemoteUserInfo.

To make this work I created 2 web services and called them
RemoteUserEarth and RemoteUserSaturn. Both Services are identical except
for the URL they point to and their Namespaces
(ClassLibrary4.RemoteUserEarth and ClassLibrary4.RemoteUserEarth).

I then tried all combinations of defines to make this work and kept
coming up with compiler errors - mainly "Cannot Implicitly assign"
errors.

I came closest with:

ClassLibrary4.RemoteUserEarth.RemoteUserServiceSer vice
remoteUserServiceEarth = new
ClassLibrary4.RemoteUserEarth.RemoteUserServiceSer vice();

ClassLibrary4.RemoteUserSaturn.RemoteUserServiceSe rvice
remoteUserServiceSaturn = new
ClassLibrary4.RemoteUserSaturn.RemoteUserServiceSe rvice();

object remoteUserService;

remoteUserService =
(ClassLibrary4.RemoteUserSaturn.RemoteUserServiceS ervice)remoteUserServiceTfs;

This compiles fine, but I can't use the remoteUserService in my code as
it is an object.

ruDataBean = remoteUserService.fetchRemoteUserInfo(
userID,
"swpays",
"10.0.0.25",
"C", //Client (employer)
sessionID);

This gives me an error "'object' does not contain a definition for
'fetchRemoteUserInfo'".

What I am trying to do is get remoteUserService be the generic class that
I can using throughout my code. I don't want to create multiple
instances of the same code when the only difference is the machine I
point to. If I then have to set up a 3rd machine, I would have recreate
all my code again for the 3rd machine. I would much rather just set up
another variable, such as remoteUserServiceMars which I just assign to
remoteUserService when I point to that machine.

Can this be done?

Thanks,

Tom


Apr 3 '06 #3
The webservices that shipped with 1.1 or in parallel is what i am using...
There are certain datatypes that it will not understand.. like I can't send
a DataTable as a parameter, have to wrap it in a DataSet and send it...
Maybe the string[][] is a problem.. I have not tried that parameter.. if you
get a error when adding or creating object? what is the error message can
you post it?

Vijay

"tshad" <ts**********@ftsolutions.com> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
"Vijay" <vi***@msdiscussions.com> wrote in message
news:Oy**************@TK2MSFTNGP12.phx.gbl...
Tshad,

Changing URL to connect to different webservices is the best and easy
way..I do it all the time and it works great, we connect to different
servers also.. Could you post a sample of your problem in ability to
connect to different URL.


I tried that using the following:

remoteUserService.Url =
http://10.0.0.25:8080/data/services/RemoteUserService;

newHireService.Url = http://10.0.0.25:8080/data/services/newHireService;

employeeTaxService.Url =
http://10.0.0.25:8080/data/services/employeeTaxService;

This worked for the first one, but not the second one. These were written
in Java, and we do have a problem with creating the proxy when using
multi-dimensional strings ([][]).

I don't know if this is the case, but what I am trying to do is just
create all the web service Object and then create generic object that I
change to whichever service I need to access.

I just know how to get this to work. I thought I had it finally setting
up the generic service as an object and I seem to be able to assign the
actual service to it, but I can't seem to access the methods (and I assume
the properties).

Is there a way to make this method work?

Thanks,

Tom

Vijay

"tshad" <ts**********@ftsolutions.com> wrote in message
news:u7**************@TK2MSFTNGP14.phx.gbl...
This is a little complicated to explain but I have some web services on
a machine that work great.

The problem is that I have run into a situation where I need to set up
my program to access one or another (could also be 3) different web
servers to use these Web Services. The Web Services are identical on
all the machines. I tried just changing the URL of the Web Services and
cannot make it work. I then decided to create 2 identical web services
(one for each machine) and then use a generic type to use in my code.

The 2 web Servers are Earth and Saturn.

I originally had a Web Service called RemoteUserService, which has a
method fetchRemoteUserInfo.

To make this work I created 2 web services and called them
RemoteUserEarth and RemoteUserSaturn. Both Services are identical
except for the URL they point to and their Namespaces
(ClassLibrary4.RemoteUserEarth and ClassLibrary4.RemoteUserEarth).

I then tried all combinations of defines to make this work and kept
coming up with compiler errors - mainly "Cannot Implicitly assign"
errors.

I came closest with:

ClassLibrary4.RemoteUserEarth.RemoteUserServiceSer vice
remoteUserServiceEarth = new
ClassLibrary4.RemoteUserEarth.RemoteUserServiceSer vice();

ClassLibrary4.RemoteUserSaturn.RemoteUserServiceSe rvice
remoteUserServiceSaturn = new
ClassLibrary4.RemoteUserSaturn.RemoteUserServiceSe rvice();

object remoteUserService;

remoteUserService =
(ClassLibrary4.RemoteUserSaturn.RemoteUserServiceS ervice)remoteUserServiceTfs;

This compiles fine, but I can't use the remoteUserService in my code as
it is an object.

ruDataBean = remoteUserService.fetchRemoteUserInfo(
userID,
"swpays",
"10.0.0.25",
"C", //Client (employer)
sessionID);

This gives me an error "'object' does not contain a definition for
'fetchRemoteUserInfo'".

What I am trying to do is get remoteUserService be the generic class
that I can using throughout my code. I don't want to create multiple
instances of the same code when the only difference is the machine I
point to. If I then have to set up a 3rd machine, I would have recreate
all my code again for the 3rd machine. I would much rather just set up
another variable, such as remoteUserServiceMars which I just assign to
remoteUserService when I point to that machine.

Can this be done?

Thanks,

Tom



Apr 4 '06 #4
The webservices are created by another company that does our software to
access their functions. These are written in Java.

The error I get is (first line is the important one):
************************************************** ************************************************** ******
System.InvalidOperationException: There is an error in XML document (43,
19). ---> System.InvalidCastException: Cannot assign object of type
System.String[][] to an object of type System.String[].
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read3_RemoteUserDataBean()
at
System.Xml.Serialization.XmlSerializationReader.Re adReferencingElement(String
name, String ns, Boolean elementCanBeType, String& fixupReference)
at
System.Xml.Serialization.XmlSerializationReader.Re adReferencedElements()
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read6_fetchRemoteUserInfoRespo nse()
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader)
at
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
methodName, Object[] parameters)
at
ClassLibrary4.RemoteUser.RemoteUserServiceService. fetchRemoteUserInfo(String
in0, String in1, String in2, String in3, String in4)
at MyFunctions.NewHire.NewHireLogon(String sessionID)
at MyFunctions.NewHire..ctor()
at TestDll.Class1.Main(String[] args) in
c:\vsprojects\testdll\class1.cs:line 24
************************************************** ************************************************** ****************

This says I need to go into the Proxy (web reference.cs) code that VS
creates. Part of the code looks like:

************************************************** ******************************************
[System.Xml.Serialization.SoapTypeAttribute("Remote UserDataBean",
"com.fwdco.wsbeans")]

public class RemoteUserDataBean{
/// <remarks/>

public string employeeId;
/// <remarks/>

public string[] employerList;
/// <remarks/>

public string ipAddress;
/// <remarks/>

public string password;
/// <remarks/>

public string peoContactEmail;
/// <remarks/>

public string userName;
/// <remarks/>

public string valid;

}

************************************************** ********************************************

The problem is the emailList (in this case):

public string[] employerList;
it should be

public string[][] employerList;

Whenever I add one of these web services I have to find all these variables
and change them to make them work. You have to know which ones are
multi-dimensional as some are not and the [] is correct.

Tom

"Vijay" <vi***@msdiscussions.com> wrote in message
news:%2********************@TK2MSFTNGP09.phx.gbl.. .
The webservices that shipped with 1.1 or in parallel is what i am using...
There are certain datatypes that it will not understand.. like I can't
send a DataTable as a parameter, have to wrap it in a DataSet and send
it... Maybe the string[][] is a problem.. I have not tried that
parameter.. if you get a error when adding or creating object? what is the
error message can you post it?

Vijay

"tshad" <ts**********@ftsolutions.com> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
"Vijay" <vi***@msdiscussions.com> wrote in message
news:Oy**************@TK2MSFTNGP12.phx.gbl...
Tshad,

Changing URL to connect to different webservices is the best and easy
way..I do it all the time and it works great, we connect to different
servers also.. Could you post a sample of your problem in ability to
connect to different URL.


I tried that using the following:

remoteUserService.Url =
http://10.0.0.25:8080/data/services/RemoteUserService;

newHireService.Url = http://10.0.0.25:8080/data/services/newHireService;

employeeTaxService.Url =
http://10.0.0.25:8080/data/services/employeeTaxService;

This worked for the first one, but not the second one. These were
written in Java, and we do have a problem with creating the proxy when
using multi-dimensional strings ([][]).

I don't know if this is the case, but what I am trying to do is just
create all the web service Object and then create generic object that I
change to whichever service I need to access.

I just know how to get this to work. I thought I had it finally setting
up the generic service as an object and I seem to be able to assign the
actual service to it, but I can't seem to access the methods (and I
assume the properties).

Is there a way to make this method work?

Thanks,

Tom

Vijay

"tshad" <ts**********@ftsolutions.com> wrote in message
news:u7**************@TK2MSFTNGP14.phx.gbl...
This is a little complicated to explain but I have some web services on
a machine that work great.

The problem is that I have run into a situation where I need to set up
my program to access one or another (could also be 3) different web
servers to use these Web Services. The Web Services are identical on
all the machines. I tried just changing the URL of the Web Services and
cannot make it work. I then decided to create 2 identical web services
(one for each machine) and then use a generic type to use in my code.

The 2 web Servers are Earth and Saturn.

I originally had a Web Service called RemoteUserService, which has a
method fetchRemoteUserInfo.

To make this work I created 2 web services and called them
RemoteUserEarth and RemoteUserSaturn. Both Services are identical
except for the URL they point to and their Namespaces
(ClassLibrary4.RemoteUserEarth and ClassLibrary4.RemoteUserEarth).

I then tried all combinations of defines to make this work and kept
coming up with compiler errors - mainly "Cannot Implicitly assign"
errors.

I came closest with:

ClassLibrary4.RemoteUserEarth.RemoteUserServiceSer vice
remoteUserServiceEarth = new
ClassLibrary4.RemoteUserEarth.RemoteUserServiceSer vice();

ClassLibrary4.RemoteUserSaturn.RemoteUserServiceSe rvice
remoteUserServiceSaturn = new
ClassLibrary4.RemoteUserSaturn.RemoteUserServiceSe rvice();

object remoteUserService;

remoteUserService =
(ClassLibrary4.RemoteUserSaturn.RemoteUserServiceS ervice)remoteUserServiceTfs;

This compiles fine, but I can't use the remoteUserService in my code as
it is an object.

ruDataBean = remoteUserService.fetchRemoteUserInfo(
userID,
"swpays",
"10.0.0.25",
"C", //Client (employer)
sessionID);

This gives me an error "'object' does not contain a definition for
'fetchRemoteUserInfo'".

What I am trying to do is get remoteUserService be the generic class
that I can using throughout my code. I don't want to create multiple
instances of the same code when the only difference is the machine I
point to. If I then have to set up a 3rd machine, I would have
recreate all my code again for the 3rd machine. I would much rather
just set up another variable, such as remoteUserServiceMars which I
just assign to remoteUserService when I point to that machine.

Can this be done?

Thanks,

Tom



Apr 4 '06 #5
Tshad.. did u get this to work??

VJ

"tshad" <ts**********@ftsolutions.com> wrote in message
news:ek**************@TK2MSFTNGP12.phx.gbl...
The webservices are created by another company that does our software to
access their functions. These are written in Java.

The error I get is (first line is the important one):
************************************************** ************************************************** ******
System.InvalidOperationException: There is an error in XML document (43,
19). ---> System.InvalidCastException: Cannot assign object of type
System.String[][] to an object of type System.String[].
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read3_RemoteUserDataBean()
at
System.Xml.Serialization.XmlSerializationReader.Re adReferencingElement(String
name, String ns, Boolean elementCanBeType, String& fixupReference)
at
System.Xml.Serialization.XmlSerializationReader.Re adReferencedElements()
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read6_fetchRemoteUserInfoRespo nse()
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader)
at
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
methodName, Object[] parameters)
at
ClassLibrary4.RemoteUser.RemoteUserServiceService. fetchRemoteUserInfo(String
in0, String in1, String in2, String in3, String in4)
at MyFunctions.NewHire.NewHireLogon(String sessionID)
at MyFunctions.NewHire..ctor()
at TestDll.Class1.Main(String[] args) in
c:\vsprojects\testdll\class1.cs:line 24
************************************************** ************************************************** ****************

This says I need to go into the Proxy (web reference.cs) code that VS
creates. Part of the code looks like:

************************************************** ******************************************
[System.Xml.Serialization.SoapTypeAttribute("Remote UserDataBean",
"com.fwdco.wsbeans")]

public class RemoteUserDataBean{
/// <remarks/>

public string employeeId;
/// <remarks/>

public string[] employerList;
/// <remarks/>

public string ipAddress;
/// <remarks/>

public string password;
/// <remarks/>

public string peoContactEmail;
/// <remarks/>

public string userName;
/// <remarks/>

public string valid;

}

************************************************** ********************************************

The problem is the emailList (in this case):

public string[] employerList;
it should be

public string[][] employerList;

Whenever I add one of these web services I have to find all these
variables and change them to make them work. You have to know which ones
are multi-dimensional as some are not and the [] is correct.

Tom

"Vijay" <vi***@msdiscussions.com> wrote in message
news:%2********************@TK2MSFTNGP09.phx.gbl.. .
The webservices that shipped with 1.1 or in parallel is what i am
using... There are certain datatypes that it will not understand.. like I
can't send a DataTable as a parameter, have to wrap it in a DataSet and
send it... Maybe the string[][] is a problem.. I have not tried that
parameter.. if you get a error when adding or creating object? what is
the error message can you post it?

Vijay

"tshad" <ts**********@ftsolutions.com> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
"Vijay" <vi***@msdiscussions.com> wrote in message
news:Oy**************@TK2MSFTNGP12.phx.gbl...
Tshad,

Changing URL to connect to different webservices is the best and easy
way..I do it all the time and it works great, we connect to different
servers also.. Could you post a sample of your problem in ability to
connect to different URL.

I tried that using the following:

remoteUserService.Url =
http://10.0.0.25:8080/data/services/RemoteUserService;

newHireService.Url = http://10.0.0.25:8080/data/services/newHireService;

employeeTaxService.Url =
http://10.0.0.25:8080/data/services/employeeTaxService;

This worked for the first one, but not the second one. These were
written in Java, and we do have a problem with creating the proxy when
using multi-dimensional strings ([][]).

I don't know if this is the case, but what I am trying to do is just
create all the web service Object and then create generic object that I
change to whichever service I need to access.

I just know how to get this to work. I thought I had it finally setting
up the generic service as an object and I seem to be able to assign the
actual service to it, but I can't seem to access the methods (and I
assume the properties).

Is there a way to make this method work?

Thanks,

Tom

Vijay

"tshad" <ts**********@ftsolutions.com> wrote in message
news:u7**************@TK2MSFTNGP14.phx.gbl...
> This is a little complicated to explain but I have some web services
> on a machine that work great.
>
> The problem is that I have run into a situation where I need to set up
> my program to access one or another (could also be 3) different web
> servers to use these Web Services. The Web Services are identical on
> all the machines. I tried just changing the URL of the Web Services
> and cannot make it work. I then decided to create 2 identical web
> services (one for each machine) and then use a generic type to use in
> my code.
>
> The 2 web Servers are Earth and Saturn.
>
> I originally had a Web Service called RemoteUserService, which has a
> method fetchRemoteUserInfo.
>
> To make this work I created 2 web services and called them
> RemoteUserEarth and RemoteUserSaturn. Both Services are identical
> except for the URL they point to and their Namespaces
> (ClassLibrary4.RemoteUserEarth and ClassLibrary4.RemoteUserEarth).
>
> I then tried all combinations of defines to make this work and kept
> coming up with compiler errors - mainly "Cannot Implicitly assign"
> errors.
>
> I came closest with:
>
> ClassLibrary4.RemoteUserEarth.RemoteUserServiceSer vice
> remoteUserServiceEarth = new
> ClassLibrary4.RemoteUserEarth.RemoteUserServiceSer vice();
>
> ClassLibrary4.RemoteUserSaturn.RemoteUserServiceSe rvice
> remoteUserServiceSaturn = new
> ClassLibrary4.RemoteUserSaturn.RemoteUserServiceSe rvice();
>
> object remoteUserService;
>
> remoteUserService =
> (ClassLibrary4.RemoteUserSaturn.RemoteUserServiceS ervice)remoteUserServiceTfs;
>
> This compiles fine, but I can't use the remoteUserService in my code
> as it is an object.
>
> ruDataBean = remoteUserService.fetchRemoteUserInfo(
> userID,
> "swpays",
> "10.0.0.25",
> "C", //Client (employer)
> sessionID);
>
> This gives me an error "'object' does not contain a definition for
> 'fetchRemoteUserInfo'".
>
> What I am trying to do is get remoteUserService be the generic class
> that I can using throughout my code. I don't want to create multiple
> instances of the same code when the only difference is the machine I
> point to. If I then have to set up a 3rd machine, I would have
> recreate all my code again for the 3rd machine. I would much rather
> just set up another variable, such as remoteUserServiceMars which I
> just assign to remoteUserService when I point to that machine.
>
> Can this be done?
>
> Thanks,
>
> Tom
>
>



Apr 4 '06 #6
No, it is getting very frustrating.

I think I have a better example, to show what I want to do.

If I have the following File with 3 Namespaces:
*****************************************
using System;

namespace News1
{
public class NewsItem
{
public string Headline = "This is News1.NewsItem.Headline";
}

public class NewsItemModules : NewsItem
{
public string GetNewsItem()
{
return Headline;
}
}
}
namespace News2
{
public class NewsItem
{
public string Headline = "This is News2.NewsItem.Headline";
}

public class NewsItemModules : NewsItem
{
public string GetNewsItem()
{
return Headline;
}
}
}
namespace News3
{
public class NewsItem
{
public string Headline = "This is News3.NewsItem.Headline";
}

public class NewsItemModules : NewsItem
{
public string GetNewsItem()
{
return Headline;
}
}
}
******************************************

These are identical namespaces (except for the string - but the structure is
all the same).

Now I have the following:

************************************************** **********************
using System;
using News1;
using News2;
using News3;

namespace MultiNamespaces
{
class Class1
{
static NewsItemModules theHeadline;

[STAThread]
static void Main(string[] args)
{
theHeadline = new NewsItemModules();
displayHeadline();
Console.WriteLine("Press any key to exit!");
Console.ReadLine();
}

static void displayHeadline()
{
Console.WriteLine(theHeadline.GetNewsItem());
}
}
}
************************************************** ***********************

I was having a problem getting the code to work until I used static, but
that is another issue.

If you comment out:

using News2;
using News3;

This works fine.

But what I want to do is set up a global variable (theHeadline).

I then want to instatiate the variable theHeadline based on some value
passed so that you would have something like:

if (x = 1)
{
theHeadline = new news1.NewsItemModules();
}

if (x = 2)
{
theHeadline = new news2.NewsItemModules();
}

if (x = 2)
{
theHeadline = new news2.NewsItemModules();
}

From that point all the functions in the class should be able to access the
properties and methods in theHeadline.

I was looking at maybe using a generic namespace/class where one of my
defined classes can override it or maybe an interface.

The problem is you apparently can't set it to one of the namespaces/classes
and then assign it to another class. If you were to do something like:
************************************************** **
class Class1
{
static News1.NewsItemModules theHeadline;

[STAThread]
static void Main(string[] args)
{
theHeadline = new News1.NewsItemModules();
theHeadline = new News2.NewsItemModules();
************************************************** **

This would give you a compiler error of:

Cannot implicitly convert type 'News2.NewsItemModules' to
'News1.NewsItemModules'

You also have to keep in mind that I have no access to the namespaces
(news1,news2,news3). These were written my someone else. I just know what
the methods are.

Hopefully, this explains what I am trying to do. Took awhile to put it
together.

Thanks,

Tom
"Vijay" <vi***@msdiscussions.com> wrote in message
news:ej**************@TK2MSFTNGP02.phx.gbl...
Tshad.. did u get this to work??

VJ

Apr 5 '06 #7
"tshad" <ts**********@ftsolutions.com> wrote in message
news:Oa**************@TK2MSFTNGP04.phx.gbl...
<snip the example>
Hopefully, this explains what I am trying to do. Took awhile to put it together.


Try something like this:
I intentionally made the external services have different methods

----------------------------------------------------
// represents some external feed out of your control
namespace Fox
{
public class NewsClient
{
public string GetHeadLine()
{
return "FoxHeadLine";
}
}
}
----------------------------------------------------
// represents some external feed out of your control
namespace CNN
{
public class NewsTicker
{
public string GimmeTheNews()
{
return "CNNHeadLine";
}
}
}
----------------------------------------------------
// In house stuff that wraps the external stuff
namespace News
{
public interface INewsFeed
{
string GetNewsItem();
}

// This can be in the News namespace or anywhere else
public class FoxNewsFeed : INewsFeed
{
private Fox.NewsClient news = new Fox.NewsClient();

public string GetNewsItem()
{
return news.GetHeadLine();;
}
}

// This can be in the News namespace or anywhere else
public class CNNNewsFeed : INewsFeed
{
private CNN.NewsTicker news = new CNN.NewsTicker();

public string GetNewsItem()
{
return news.GimmeTheNews();;
}
}
}

-----------------------------------------------------------
// Test harness

using System;
using News;

namespace MultiNamespaces
{
class Class1
{
static INewsFeed theHeadline;

static void Main(string[] args)
{
theHeadline = new FoxNewsFeed();
displayHeadline();
theHeadline = new CNNNewsFeed();
displayHeadline();
}

static void displayHeadline()
{
Console.WriteLine(theHeadline.GetNewsItem());
}
}
}

Good Luck
Bill


Apr 5 '06 #8
"tshad" <ts**********@ftsolutions.com> wrote:
I then want to instatiate the variable theHeadline based on some value
passed so that you would have something like:
if (x = 1) theHeadline = new news1.NewsItemModules();
else if (x = 2) theHeadline = new news2.NewsItemModules();
You also have to keep in mind that I have no access to the namespaces
(news1,news2,news3). These were written my someone else. I just know what
the methods are.


So you can't change the original classes, I suppose. In that case what
you need is "Dynamic Dispatch". This is how other languages like
Python and Smalltalk work. It's not how statically-typed languages
like C# work. You can achieve the same dynamic-dispatch effect,
though, through reflection:

using System.Reflection;

class DynamicDispatcher
{ object Modules;
public DynamicDispatcher(object modules) {Modules=modules;}

public string GetNewsItem()
{ MethodInfo[] mis =
Modules.GetType().GetMethods(BindingFlags.Public|B indingFlags.Instance);
foreach (MethodInfo mi in mis)
{ if (mi.Name=="GetNewsItem" && mi.ReturnType==typeof(string) &&
mi.GetParameters().Length==0) return mi.Invoke(Modules,null) as
string;
}
throw new NotImplementedException("GetNewsItem");
}
}
Then call it like this:

if (x==1) theHeadline = new DynamicDispatch(new
News1.NewsItemModules());
else if (x==2) theHeadline = new DynamicDispatch(new
News2.NewsItemModules());
else theHeadline = new DynamicDispatch(new News3.NewsItemModules());

--
Lucian

Apr 5 '06 #9
This looks like what I am looking for.

I was able to start to get this to work.

I was having a problem with parameters, however.

In your example, how would you change it so that the 2 actual methods are
something like:

public string GetHeadLine(string a, string b, int c)
and
public string GimmeTheNews(string a, string b, int c)

I was getting an error saying there are no occurrences with 0 parameters,
but couldn't get the interface section set up correctly.

Also, why do you have 2 semicolons after "return news.GetHeadLine();;"?

Thanks,

Tom

"Bill Butler" <qw****@asdf.com> wrote in message
news:KtHYf.4191$lz3.3949@trndny05...
"tshad" <ts**********@ftsolutions.com> wrote in message
news:Oa**************@TK2MSFTNGP04.phx.gbl...
<snip the example>
Hopefully, this explains what I am trying to do. Took awhile to put it
together.


Try something like this:
I intentionally made the external services have different methods

----------------------------------------------------
// represents some external feed out of your control
namespace Fox
{
public class NewsClient
{
public string GetHeadLine()
{
return "FoxHeadLine";
}
}
}
----------------------------------------------------
// represents some external feed out of your control
namespace CNN
{
public class NewsTicker
{
public string GimmeTheNews()
{
return "CNNHeadLine";
}
}
}
----------------------------------------------------
// In house stuff that wraps the external stuff
namespace News
{
public interface INewsFeed
{
string GetNewsItem();
}

// This can be in the News namespace or anywhere else
public class FoxNewsFeed : INewsFeed
{
private Fox.NewsClient news = new Fox.NewsClient();

public string GetNewsItem()
{
return news.GetHeadLine();;
}
}

// This can be in the News namespace or anywhere else
public class CNNNewsFeed : INewsFeed
{
private CNN.NewsTicker news = new CNN.NewsTicker();

public string GetNewsItem()
{
return news.GimmeTheNews();;
}
}
}

-----------------------------------------------------------
// Test harness

using System;
using News;

namespace MultiNamespaces
{
class Class1
{
static INewsFeed theHeadline;

static void Main(string[] args)
{
theHeadline = new FoxNewsFeed();
displayHeadline();
theHeadline = new CNNNewsFeed();
displayHeadline();
}

static void displayHeadline()
{
Console.WriteLine(theHeadline.GetNewsItem());
}
}
}

Good Luck
Bill

Apr 5 '06 #10
Never mind on the parameters, I figured that out.

But not the ;;.

I am having a problem with passing back a class, however. I am going to
modify the example and see if I can make it happen there.

In a nutshell the error I am getting is:

C:\VSProjects\ClassLibrary4\FWWebServices.cs(14): Cannot implicitly convert
type 'ClassLibrary4.RemoteUserEarth.RemoteUserDataBean' to
'FWWebServices.RemoteUserDataBean' and
'ClassLibrary4.RemoteUserEarth.RemoteUserDataBean' is the exact same class
but in the external namespace.

I assume I would have to setup an inteface for this also, just not sure how
to do it.

Thanks,

Tom

Where RemoteUserDataBean is the Class in my interface section and
"tshad" <ts**********@ftsolutions.com> wrote in message
news:en**************@TK2MSFTNGP04.phx.gbl...
This looks like what I am looking for.

I was able to start to get this to work.

I was having a problem with parameters, however.

In your example, how would you change it so that the 2 actual methods are
something like:

public string GetHeadLine(string a, string b, int c)
and
public string GimmeTheNews(string a, string b, int c)

I was getting an error saying there are no occurrences with 0 parameters,
but couldn't get the interface section set up correctly.

Also, why do you have 2 semicolons after "return news.GetHeadLine();;"?

Thanks,

Tom

"Bill Butler" <qw****@asdf.com> wrote in message
news:KtHYf.4191$lz3.3949@trndny05...
"tshad" <ts**********@ftsolutions.com> wrote in message
news:Oa**************@TK2MSFTNGP04.phx.gbl...
<snip the example>
Hopefully, this explains what I am trying to do. Took awhile to put it
together.


Try something like this:
I intentionally made the external services have different methods

----------------------------------------------------
// represents some external feed out of your control
namespace Fox
{
public class NewsClient
{
public string GetHeadLine()
{
return "FoxHeadLine";
}
}
}
----------------------------------------------------
// represents some external feed out of your control
namespace CNN
{
public class NewsTicker
{
public string GimmeTheNews()
{
return "CNNHeadLine";
}
}
}
----------------------------------------------------
// In house stuff that wraps the external stuff
namespace News
{
public interface INewsFeed
{
string GetNewsItem();
}

// This can be in the News namespace or anywhere else
public class FoxNewsFeed : INewsFeed
{
private Fox.NewsClient news = new Fox.NewsClient();

public string GetNewsItem()
{
return news.GetHeadLine();;
}
}

// This can be in the News namespace or anywhere else
public class CNNNewsFeed : INewsFeed
{
private CNN.NewsTicker news = new CNN.NewsTicker();

public string GetNewsItem()
{
return news.GimmeTheNews();;
}
}
}

-----------------------------------------------------------
// Test harness

using System;
using News;

namespace MultiNamespaces
{
class Class1
{
static INewsFeed theHeadline;

static void Main(string[] args)
{
theHeadline = new FoxNewsFeed();
displayHeadline();
theHeadline = new CNNNewsFeed();
displayHeadline();
}

static void displayHeadline()
{
Console.WriteLine(theHeadline.GetNewsItem());
}
}
}

Good Luck
Bill


Apr 5 '06 #11
Here is the new problem in the sample I had. I modified it like your
example and it worked fine when the return value was a string.

My problem is the external classes have a class that they are defining and
returning. This class is exactly the same in each Namespace, just like the
method was.

I am not sure if I need to create a new interface or do I put the class in
the original interface.

Here is the code and the error I get is:

C:\VSProjects\MultiNamespaces\Class3.cs(30): Cannot implicitly convert type
'News3.NewsDataBean' to 'string'

which at this point makes sense since the interface has the return a string,
but the external functions return a class (NewsDataBean). I obviously have
to change the string returns to a generic class.

class1.cs The program that uses the classes
************************************************** ************************
using System;
using News;

namespace MultiNamespaces
{
class Class1
{
static INewsFeed theHeadline;

[STAThread]
static void Main(string[] args)
{
theHeadline = new FoxNewsFeed();
displayHeadline();
theHeadline = new CNNNewsFeed();
displayHeadline();
theHeadline = new ABCNewsFeed();
displayHeadline();

Console.WriteLine("Press any key to exit!");
Console.ReadLine();
}

static void displayHeadline()
{
Console.WriteLine(theHeadline.GetNewsItem("first", "second","third"));
}
}
}
************************************************** ************************

class2.cs The external Namespaces/Classes
************************************************** ************************
using System;

namespace News1
{
public class NewsItem
{
public string Headline = "This is News1.NewsItem.Headline";
}

public class NewsItemModules : NewsItem
{
public NewsDataBean GetNewsItem(string a,string b,string c)
{
NewsDataBean NewsDB = new NewsDataBean();
NewsDB.final = a + " " + b + " " + c + " " + Headline;
return NewsDB;
}
}
public class NewsDataBean : NewsDataBean2
{
public string final;
}
public class NewsDataBean2
{
public string something;
}
}
namespace News2
{
public class NewsItem
{
public string Headline = "This is News2.NewsItem.Headline";
}

public class NewsItemModules : NewsItem
{
public NewsDataBean GetNewsItem(string a,string b,string c)
{
NewsDataBean NewsDB = new NewsDataBean();
NewsDB.final = a + " " + b + " " + c + " " + Headline;
return NewsDB;
}
}
public class NewsDataBean : NewsDataBean2
{
public string final;
}
public class NewsDataBean2
{
public string something;
}
}
namespace News3
{
public class NewsItem
{
public string Headline = "This is News3.NewsItem.Headline";
}

public class NewsItemModules : NewsItem
{
public NewsDataBean GetNewsItem(string a,string b,string c)
{
NewsDataBean NewsDB = new NewsDataBean();
NewsDB.final = a + " " + b + " " + c + " " + Headline;
return NewsDB;
}
}
public class NewsDataBean : NewsDataBean2
{
public string final;
}
public class NewsDataBean2
{
public string something;
}
}
************************************************** ************************

class3.cs My interface that uses the external Namespaces
************************************************** ************************
using System;

namespace News
{
public interface INewsFeed
{
string GetNewsItem(string a, string b, string c);
}
public class FoxNewsFeed : INewsFeed
{
private News1.NewsItemModules news = new News1.NewsItemModules();
public string GetNewsItem(string a,string b, string c)
{
return news.GetNewsItem(a,b,c);;
}
}
public class CNNNewsFeed : INewsFeed
{
private News2.NewsItemModules news = new News2.NewsItemModules();
public string GetNewsItem(string a,string b, string c)
{
return news.GetNewsItem(a,b,c);;
}
}
public class ABCNewsFeed : INewsFeed
{
private News3.NewsItemModules news = new News3.NewsItemModules();
public string GetNewsItem(string a,string b, string c)
{
return news.GetNewsItem(a,b,c);;
}
}
}
************************************************** ************************

Thanks,

Tom

"tshad" <ts**********@ftsolutions.com> wrote in message
news:O%****************@TK2MSFTNGP04.phx.gbl...
Never mind on the parameters, I figured that out.

But not the ;;.

I am having a problem with passing back a class, however. I am going to
modify the example and see if I can make it happen there.

In a nutshell the error I am getting is:

C:\VSProjects\ClassLibrary4\FWWebServices.cs(14): Cannot implicitly
convert type 'ClassLibrary4.RemoteUserEarth.RemoteUserDataBean' to
'FWWebServices.RemoteUserDataBean' and
'ClassLibrary4.RemoteUserEarth.RemoteUserDataBean' is the exact same class
but in the external namespace.

I assume I would have to setup an inteface for this also, just not sure
how to do it.

Thanks,

Tom

Where RemoteUserDataBean is the Class in my interface section and
"tshad" <ts**********@ftsolutions.com> wrote in message
news:en**************@TK2MSFTNGP04.phx.gbl...
This looks like what I am looking for.

I was able to start to get this to work.

I was having a problem with parameters, however.

In your example, how would you change it so that the 2 actual methods are
something like:

public string GetHeadLine(string a, string b, int c)
and
public string GimmeTheNews(string a, string b, int c)

I was getting an error saying there are no occurrences with 0 parameters,
but couldn't get the interface section set up correctly.

Also, why do you have 2 semicolons after "return news.GetHeadLine();;"?

Thanks,

Tom

"Bill Butler" <qw****@asdf.com> wrote in message
news:KtHYf.4191$lz3.3949@trndny05...
"tshad" <ts**********@ftsolutions.com> wrote in message
news:Oa**************@TK2MSFTNGP04.phx.gbl...
<snip the example>

Hopefully, this explains what I am trying to do. Took awhile to put it
together.

Try something like this:
I intentionally made the external services have different methods

----------------------------------------------------
// represents some external feed out of your control
namespace Fox
{
public class NewsClient
{
public string GetHeadLine()
{
return "FoxHeadLine";
}
}
}
----------------------------------------------------
// represents some external feed out of your control
namespace CNN
{
public class NewsTicker
{
public string GimmeTheNews()
{
return "CNNHeadLine";
}
}
}
----------------------------------------------------
// In house stuff that wraps the external stuff
namespace News
{
public interface INewsFeed
{
string GetNewsItem();
}

// This can be in the News namespace or anywhere else
public class FoxNewsFeed : INewsFeed
{
private Fox.NewsClient news = new Fox.NewsClient();

public string GetNewsItem()
{
return news.GetHeadLine();;
}
}

// This can be in the News namespace or anywhere else
public class CNNNewsFeed : INewsFeed
{
private CNN.NewsTicker news = new CNN.NewsTicker();

public string GetNewsItem()
{
return news.GimmeTheNews();;
}
}
}

-----------------------------------------------------------
// Test harness

using System;
using News;

namespace MultiNamespaces
{
class Class1
{
static INewsFeed theHeadline;

static void Main(string[] args)
{
theHeadline = new FoxNewsFeed();
displayHeadline();
theHeadline = new CNNNewsFeed();
displayHeadline();
}

static void displayHeadline()
{
Console.WriteLine(theHeadline.GetNewsItem());
}
}
}

Good Luck
Bill



Apr 5 '06 #12

"tshad" <ts**********@ftsolutions.com> wrote in message
news:O%****************@TK2MSFTNGP04.phx.gbl...
Never mind on the parameters, I figured that out.

But not the ;;.


Typo...Sorry

<snip>

I will respond to the rest after I eat dinner :^)

Bill
Apr 5 '06 #13

"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...

Hi Tom,

First a few comments

Lets's step back for a second.
If the Web services on the 3 machines a identical, then you *should* be able to simply change the
URL in order to point to another identical service. You mentioned that you couldn't get this to
work, but you didn't elaborate.
I would invest some effort in this direction, as it would make your code cleaner in the long run. It
also makes sense that if the only difference between 3 Web Services is their URL, then they should
be represented by the same class. I don't mean classes with identical structure in different
namespaces. I mean the *same* class.

However, if you wish to go forward
change this
public string GetNewsItem(string a,string b, string c)
{
return news.GetNewsItem(a,b,c);
}

to this
public string GetNewsItem(string a,string b, string c)
{
News3.NewsDataBean bean = news.GetNewsItem(a,b,c);
return bean.final;
}
I am a bit curious as to the reason for your inheritance structure
Why do you need a NewsItem and a NewsItemModules class?
Why do you need a NewsDataBean and a NewsDataBean2?
Bill
Apr 7 '06 #14
"Bill Butler" <qw****@asdf.com> wrote in message
news:GHlZf.9895$lz3.5908@trndny05...

"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...

Hi Tom,

First a few comments

Lets's step back for a second.
If the Web services on the 3 machines a identical, then you *should* be
able to simply change the URL in order to point to another identical
service. You mentioned that you couldn't get this to work, but you didn't
elaborate.
Actually, this was what I originally tried to do.

The Web Services are written in Java and we just have access to them. But
MS seems to have a problem with the Proxy that it builds from the wsdl. We
have another problem with multiple defined arrays (string [][]), it only
defines it as string[]. I need to manually change the proxy wherever these
show up. It may be related to the Java/MS problem.

In this case, I have 2 machines 10.0.0.3 and 10.0.0.25 both running apache
tomcat. In my program, I can add the web services from either machine with
no problem. The first service it finds fine, but the 2nd one gives us an
error and all I do is change the URL. Following is how it is set up.

RemoteUserService works fine.

But when I call newHireService.readNewHire I get the following error:

System.Web.Services.Protocols.SoapException: The AXIS engine could not find
a target service to invoke! targetService is newHireService at
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
methodName, Object[] parameters)
at ClassLibrary4.NewHire.NewHireServiceService.readNe wHire(String in0,
String in1, String in2)
at MyFunctions.NewHire..ctor()
at TestDll.Class1.Main(String[] args) in
c:\vsprojects\testdll\class1.cs:line 24

It can't seem to find the newHireService.

Here is the section of code that changes the URL and the code that calls the
2 services

************************************************** *******************************************
RemoteUserServiceService remoteUserService = new
RemoteUserServiceService();
NewHireServiceService newHireService = new NewHireServiceService();

RemoteUserDataBean ruDataBean;
NewHireDataBean nhDataBean;

public NewHire()
{
sessionID = "150";

remoteUserService.Url =
"http://10.0.0.25:8080/data_connect/services/RemoteUserService";
newHireService.Url =
"http://10.0.0.25:8080/data_connect/services/newHireService";

NewHireLogon(sessionID);
if (errorCode == 0)
{
nhDataBean = newHireService.readNewHire(
companyNumber,
userID,
sessionID);
.... other code.
private void NewHireLogon(string sessionID)
{
ruDataBean = remoteUserService.fetchRemoteUserInfo(
userID,
"sw",
"",
"C", //Client (employer)
sessionID);

errorCode = ruDataBean.errorCode;
errorMessage = ruDataBean.errorMessage;
}
************************************************** ************************************
As you can see, I set the URL, then I call both services. 1st one works and
2nd one gives the error.

I am not sure why one works and one doesn't. If I comment out the 2 lines
that change the URLs, it works fine. I assume the URLs are correct since it
finds the first one (RemoteUserServer).
I would invest some effort in this direction, as it would make your code
cleaner in the long run. It also makes sense that if the only difference
between 3 Web Services is their URL, then they should be represented by
the same class. I don't mean classes with identical structure in different
namespaces. I mean the *same* class.
I agree. It would be cleaner and would be the one I would prefer to use. I
was hoping to wrap the services in a generic one and just call the Generic
functions (as you set up with the interfaces). The only other way is to
create copies of all the calls and call one function when I need to hit one
server and the other function when I need the other servers services. In
essence, what you did with the interfaces.

However, if you wish to go forward
change this
public string GetNewsItem(string a,string b, string c)
{
return news.GetNewsItem(a,b,c);
}

to this
public string GetNewsItem(string a,string b, string c)
{
News3.NewsDataBean bean = news.GetNewsItem(a,b,c);
return bean.final;
}
I am a bit curious as to the reason for your inheritance structure
Why do you need a NewsItem and a NewsItemModules class?
Why do you need a NewsDataBean and a NewsDataBean2?
I did get the argument problem to work.

I was setting up 2 classes in one namespace just to have one class call
another class in the same namespace - as the web service does.

The DataBeans are non standard types (classes). The DataBean in Java is
just a structure. In all the examples I have seen, the returns are always
strings or ints. There is only one string type and one int type for
everyone. The Databeans are also identical, but they aren't standard types.
When you create a proxy with a class, it recreates the class in each web
service (it doesn't do that for strings).

So you can return just NewsDataBean. It has to be class.NewsDataBean or
namespace.class.NewsDataBean (not sure which). But they are different
(strings aren't - as in your example).

If I was only going to use the newsDataBean inside the classes, there
wouldn't be a problem (as in the NewsItem). But I need to get access to the
properties in the DataBean from the program that calls the Services.

In our example I am doing:

Console.WriteLine(theHeadline.GetNewsItem("first", "second","third"));

This works because I am returning a string frin GetNewsItem.

But I need to return a Structure (DataBean) which could have strings, ints,
return values, error codes, error messages, etc.

I need to be able to do something like

NewDataBean = theHeadline.GetNewsItem("first","second","third");
Console.WriteLine(NewDataBean.something)

Maybe this is getting too convoluted.

Thanks,

Tom

Bill

Apr 7 '06 #15
Comments Inline
"tshad" <ts**********@ftsolutions.com> wrote in message
news:uZ**************@TK2MSFTNGP03.phx.gbl...
"Bill Butler" <qw****@asdf.com> wrote in message news:GHlZf.9895$lz3.5908@trndny05...

"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...

Hi Tom,

First a few comments

Lets's step back for a second.
If the Web services on the 3 machines a identical, then you *should* be able to simply change the
URL in order to point to another identical service. You mentioned that you couldn't get this to
work, but you didn't elaborate.
Actually, this was what I originally tried to do.

The Web Services are written in Java and we just have access to them. But MS seems to have a
problem with the Proxy that it builds from the wsdl. We have another problem with multiple
defined arrays (string [][]), it only defines it as string[]. I need to manually change the proxy
wherever these show up. It may be related to the Java/MS problem.

In this case, I have 2 machines 10.0.0.3 and 10.0.0.25 both running apache tomcat. In my program,
I can add the web services from either machine with no problem. The first service it finds fine,
but the 2nd one gives us an error and all I do is change the URL. Following is how it is set up.

RemoteUserService works fine.

But when I call newHireService.readNewHire I get the following error:

System.Web.Services.Protocols.SoapException: The AXIS engine could not find a target service to
invoke! targetService is newHireService at
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage message,
WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String methodName, Object[]
parameters)
at ClassLibrary4.NewHire.NewHireServiceService.readNe wHire(String in0, String in1, String in2)
at MyFunctions.NewHire..ctor()
at TestDll.Class1.Main(String[] args) in c:\vsprojects\testdll\class1.cs:line 24

It can't seem to find the newHireService.

Here is the section of code that changes the URL and the code that calls the 2 services

************************************************** *******************************************
RemoteUserServiceService remoteUserService = new RemoteUserServiceService();
NewHireServiceService newHireService = new NewHireServiceService();

RemoteUserDataBean ruDataBean;
NewHireDataBean nhDataBean;

public NewHire()
{
sessionID = "150";

remoteUserService.Url = "http://10.0.0.25:8080/data_connect/services/RemoteUserService";
newHireService.Url = "http://10.0.0.25:8080/data_connect/services/newHireService";


Shouldn't that be "NewHireService"? I am not sure if case matters???


NewHireLogon(sessionID);
if (errorCode == 0)
{
nhDataBean = newHireService.readNewHire(
companyNumber,
userID,
sessionID);
... other code.
private void NewHireLogon(string sessionID)
{
ruDataBean = remoteUserService.fetchRemoteUserInfo(
userID,
"sw",
"",
"C", //Client (employer)
sessionID);

errorCode = ruDataBean.errorCode;
errorMessage = ruDataBean.errorMessage;
}
************************************************** ************************************
As you can see, I set the URL, then I call both services. 1st one works and 2nd one gives the
error.

I am not sure why one works and one doesn't. If I comment out the 2 lines that change the URLs,
it works fine. I assume the URLs are correct since it finds the first one (RemoteUserServer).
I would invest some effort in this direction, as it would make your code cleaner in the long run.
It also makes sense that if the only difference between 3 Web Services is their URL, then they
should be represented by the same class. I don't mean classes with identical structure in
different namespaces. I mean the *same* class.
I agree. It would be cleaner and would be the one I would prefer to use. I was hoping to wrap
the services in a generic one and just call the Generic functions (as you set up with the
interfaces). The only other way is to create copies of all the calls and call one function when I
need to hit one server and the other function when I need the other servers services. In essence,
what you did with the interfaces.


Absolutely, it would be much nicer.
The solution that I was presenting Is more approriate when you have Feeds from dissimilar sources.
When the Feeds are identical it makes more sense to simply have each feed be a different instance of
the same class.

However, if you wish to go forward
change this
public string GetNewsItem(string a,string b, string c)
{
return news.GetNewsItem(a,b,c);
}

to this
public string GetNewsItem(string a,string b, string c)
{
News3.NewsDataBean bean = news.GetNewsItem(a,b,c);
return bean.final;
}
I am a bit curious as to the reason for your inheritance structure
Why do you need a NewsItem and a NewsItemModules class?
Why do you need a NewsDataBean and a NewsDataBean2?
I did get the argument problem to work.

I was setting up 2 classes in one namespace just to have one class call another class in the same
namespace - as the web service does.

The DataBeans are non standard types (classes). The DataBean in Java is just a structure. In all
the examples I have seen, the returns are always strings or ints. There is only one string type
and one int type for everyone. The Databeans are also identical, but they aren't standard types.
When you create a proxy with a class, it recreates the class in each web service (it doesn't do
that for strings).

So you can return just NewsDataBean. It has to be class.NewsDataBean or
namespace.class.NewsDataBean (not sure which). But they are different (strings aren't - as in
your example).

If I was only going to use the newsDataBean inside the classes, there wouldn't be a problem (as in
the NewsItem). But I need to get access to the properties in the DataBean from the program that
calls the Services.

In our example I am doing:

Console.WriteLine(theHeadline.GetNewsItem("first", "second","third"));

This works because I am returning a string frin GetNewsItem.

But I need to return a Structure (DataBean) which could have strings, ints, return values, error
codes, error messages, etc.

I need to be able to do something like

NewDataBean = theHeadline.GetNewsItem("first","second","third");
Console.WriteLine(NewDataBean.something)

Maybe this is getting too convoluted.


This is the problem with the path we were walking down.
You would have a family classes with exactly the same structure, but no intrinsic relation between
them.
You *could* create Conversion routines for each of the beans that return a "commonBean". This is NOT
the ideal solution as it is NOT very expandible. Each additional "Identical" service would require a
set of new conversion routines.

The fact that NewHireServiceService works with the default URL, but not the changed URL sounds
suspicious.
Hopefully it is just the Case if the service name.
Good luck
Bill

Thanks,

Tom


Bill


Apr 8 '06 #16

"Bill Butler" <qw****@asdf.com> wrote in message
news:seDZf.990$_T5.968@trndny08...
Comments Inline
"tshad" <ts**********@ftsolutions.com> wrote in message
news:uZ**************@TK2MSFTNGP03.phx.gbl...
"Bill Butler" <qw****@asdf.com> wrote in message
news:GHlZf.9895$lz3.5908@trndny05...

"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...

Hi Tom,

First a few comments

Lets's step back for a second.
If the Web services on the 3 machines a identical, then you *should* be
able to simply change the URL in order to point to another identical
service. You mentioned that you couldn't get this to work, but you
didn't elaborate.
Actually, this was what I originally tried to do.

The Web Services are written in Java and we just have access to them.
But MS seems to have a problem with the Proxy that it builds from the
wsdl. We have another problem with multiple defined arrays (string
[][]), it only defines it as string[]. I need to manually change the
proxy wherever these show up. It may be related to the Java/MS problem.

In this case, I have 2 machines 10.0.0.3 and 10.0.0.25 both running
apache tomcat. In my program, I can add the web services from either
machine with no problem. The first service it finds fine, but the 2nd
one gives us an error and all I do is change the URL. Following is how
it is set up.

RemoteUserService works fine.

But when I call newHireService.readNewHire I get the following error:

System.Web.Services.Protocols.SoapException: The AXIS engine could not
find a target service to invoke! targetService is newHireService at
System.Web.Services.Protocols.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String
methodName, Object[] parameters)
at ClassLibrary4.NewHire.NewHireServiceService.readNe wHire(String in0,
String in1, String in2)
at MyFunctions.NewHire..ctor()
at TestDll.Class1.Main(String[] args) in
c:\vsprojects\testdll\class1.cs:line 24

It can't seem to find the newHireService.

Here is the section of code that changes the URL and the code that calls
the 2 services

************************************************** *******************************************
RemoteUserServiceService remoteUserService = new
RemoteUserServiceService();
NewHireServiceService newHireService = new NewHireServiceService();

RemoteUserDataBean ruDataBean;
NewHireDataBean nhDataBean;

public NewHire()
{
sessionID = "150";

remoteUserService.Url =
"http://10.0.0.25:8080/data_connect/services/RemoteUserService";
newHireService.Url =
"http://10.0.0.25:8080/data_connect/services/newHireService";


Shouldn't that be "NewHireService"? I am not sure if case matters???


You're right!!!

That solved the URL problem. I am not sure why it has to be Caps - case is
normally not an issue when dealing with other web pages.

I would still like to get my other example to work, just so I understand the
problem and how to use Interfaces over and above what we see in normal
examples on the web or in my book.

Thanks,

Tom


NewHireLogon(sessionID);
if (errorCode == 0)
{
nhDataBean = newHireService.readNewHire(
companyNumber,
userID,
sessionID);
... other code.
private void NewHireLogon(string sessionID)
{
ruDataBean = remoteUserService.fetchRemoteUserInfo(
userID,
"sw",
"",
"C", //Client (employer)
sessionID);

errorCode = ruDataBean.errorCode;
errorMessage = ruDataBean.errorMessage;
}
************************************************** ************************************
As you can see, I set the URL, then I call both services. 1st one works
and 2nd one gives the error.

I am not sure why one works and one doesn't. If I comment out the 2
lines that change the URLs, it works fine. I assume the URLs are correct
since it finds the first one (RemoteUserServer).
I would invest some effort in this direction, as it would make your code
cleaner in the long run. It also makes sense that if the only difference
between 3 Web Services is their URL, then they should be represented by
the same class. I don't mean classes with identical structure in
different namespaces. I mean the *same* class.


I agree. It would be cleaner and would be the one I would prefer to use.
I was hoping to wrap the services in a generic one and just call the
Generic functions (as you set up with the interfaces). The only other
way is to create copies of all the calls and call one function when I
need to hit one server and the other function when I need the other
servers services. In essence, what you did with the interfaces.


Absolutely, it would be much nicer.
The solution that I was presenting Is more approriate when you have Feeds
from dissimilar sources. When the Feeds are identical it makes more sense
to simply have each feed be a different instance of the same class.

However, if you wish to go forward
change this
public string GetNewsItem(string a,string b, string c)
{
return news.GetNewsItem(a,b,c);
}

to this
public string GetNewsItem(string a,string b, string c)
{
News3.NewsDataBean bean = news.GetNewsItem(a,b,c);
return bean.final;
}
I am a bit curious as to the reason for your inheritance structure
Why do you need a NewsItem and a NewsItemModules class?
Why do you need a NewsDataBean and a NewsDataBean2?


I did get the argument problem to work.

I was setting up 2 classes in one namespace just to have one class call
another class in the same namespace - as the web service does.

The DataBeans are non standard types (classes). The DataBean in Java is
just a structure. In all the examples I have seen, the returns are
always strings or ints. There is only one string type and one int type
for everyone. The Databeans are also identical, but they aren't standard
types. When you create a proxy with a class, it recreates the class in
each web service (it doesn't do that for strings).

So you can return just NewsDataBean. It has to be class.NewsDataBean or
namespace.class.NewsDataBean (not sure which). But they are different
(strings aren't - as in your example).

If I was only going to use the newsDataBean inside the classes, there
wouldn't be a problem (as in the NewsItem). But I need to get access to
the properties in the DataBean from the program that calls the Services.

In our example I am doing:

Console.WriteLine(theHeadline.GetNewsItem("first", "second","third"));

This works because I am returning a string frin GetNewsItem.

But I need to return a Structure (DataBean) which could have strings,
ints, return values, error codes, error messages, etc.

I need to be able to do something like

NewDataBean = theHeadline.GetNewsItem("first","second","third");
Console.WriteLine(NewDataBean.something)

Maybe this is getting too convoluted.


This is the problem with the path we were walking down.
You would have a family classes with exactly the same structure, but no
intrinsic relation between them.
You *could* create Conversion routines for each of the beans that return a
"commonBean". This is NOT the ideal solution as it is NOT very expandible.
Each additional "Identical" service would require a set of new conversion
routines.

The fact that NewHireServiceService works with the default URL, but not
the changed URL sounds suspicious.
Hopefully it is just the Case if the service name.
Good luck
Bill

Thanks,

Tom


Bill



Apr 10 '06 #17

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

Similar topics

3
by: Jim Newton | last post by:
hi all, i'm relatively new to python. I find it a pretty interesting language but also somewhat limiting compared to lisp. I notice that the language does provide a few lispy type nicities, but...
25
by: Lars | last post by:
Hi, I have a base class holding a generic list that needs to be accessed by both the base class and its subclasses. What is the best solution to this? I am fairly new to generics, but I am...
3
by: Tigger | last post by:
I have an object which could be compared to a DataTable/List which I am trying to genericify. I've spent about a day so far in refactoring and in the process gone through some hoops and hit some...
3
by: Simon Hart | last post by:
Hi, I am trying to implement some functionality as seen in MS CRM 3.0 whereby a basic Xml is deserialized into an object which contains properties. What I want to do from here is; cast the basic...
26
by: nyathancha | last post by:
Hi, How Do I create an instance of a derived class from an instance of a base class, essentially wrapping up an existing base class with some additional functionality. The reason I need this is...
5
by: Torben Laursen | last post by:
I am writing a COM in C# using visual studio 2005 and VSTO. Inside the code I use some support classes that are generic but they are not used in the inferface of the COM. However I still get a...
2
by: Polaris431 | last post by:
I need to implement a tree structure that can accept various types of classes or structs. When the tree is created, all of its nodes are based on a single type and not a mixture of types. ...
10
by: phancey | last post by:
I'm quite new to generics. I have 2 generic classes: MyClass<Tand MyOtherClass<T>. MyClass<Thas 2 public Add methods Add(MyOtherClass<T>); Add(MyOtherClass<Wrapper<T>>); (Wrapper<Tis another...
1
by: Charles Law | last post by:
I have a base class MyBaseClass, and several classes that inherit from it: MyClass1, MyClass2, etc. The base class implements IEnumerable(Of IMyBaseClassRow). The base class has a DataTable...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.