473,780 Members | 2,258 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with namespace

I have a problem with namespace:

I've a class in a namespace

namespace.Foo

that's used in a web method

when I reference the web method from a web service the namespace changes
because of the wsdl compiler, so now my class, in the code using the web
service reference.cs becomes

webservicenames pace.Foo

Problem is that in my web method Foo I need to call the same web method Foo
on a different machine to create a sort of NLB scheme, but the web reference
I add need a webservicenames pace.Foo parameter while I have a namespace.Foo
instance.

Code is more or less like this
public void Do(Foo parameter) { // This is namespace.Foo
if(useNLB) {
WebService ws = new WebService()
ws.url = GetNLBUrl();
Do(Foo); // This instead needs webservicenames pace.Foo
}
else { ... perform operation }
}

Is there a way to accomplish this? Obviously casting the two classes do not
work...

Regards
Massimo
Jul 4 '06 #1
3 1684
You would have to copy the data from one class to the other.
public void Do(Foo parameter) { // This is namespace.Foo
if(useNLB) {
WebService ws = new WebService()
webservicenames pace.Foo f = new webservicenames pace.Foo();
//copy properties of parameter to f
ws.url = GetNLBUrl();
Do(Foo); }
else { ... perform operation }
}
The other options (assuming the two foos are actually the same when it comes
to serialization) is that you can change the way your webproxy is generating
(to make it generate using namespace.Foo as a parameter as opposed to
creating its own). You could also use serialization to say a memorystream
(serialize namespace.Foo, deserialize as a webservicenames pace.Foo).
Generally the handling of the proxy generation is the preferred method here.

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung

"Massimo Gentilini" <ma************ **@hotmail.comw rote in message
news:et******** ******@TK2MSFTN GP02.phx.gbl...
>I have a problem with namespace:

I've a class in a namespace

namespace.Foo

that's used in a web method

when I reference the web method from a web service the namespace changes
because of the wsdl compiler, so now my class, in the code using the web
service reference.cs becomes

webservicenames pace.Foo

Problem is that in my web method Foo I need to call the same web method
Foo on a different machine to create a sort of NLB scheme, but the web
reference I add need a webservicenames pace.Foo parameter while I have a
namespace.Foo instance.

Code is more or less like this
public void Do(Foo parameter) { // This is namespace.Foo
if(useNLB) {
WebService ws = new WebService()
ws.url = GetNLBUrl();
Do(Foo); // This instead needs webservicenames pace.Foo
}
else { ... perform operation }
}

Is there a way to accomplish this? Obviously casting the two classes do
not work...

Regards
Massimo

Jul 4 '06 #2
The WSDL-proxy and the actual class are simply not directly interoperable; I
guess you're either meant to be a client or a server here...
I don't like it as a solution, but you could try serializing
(xml-serializer) whichever Foo you have as xml (e.g. to a MemoryStream),
rewind the stream and then deserialize as the other Foo... since they have
the same structure it might just work - not very efficient though...

Marc
Jul 5 '06 #3
I don't like it as a solution, but you could try serializing
(xml-serializer) whichever Foo you have as xml (e.g. to a MemoryStream),
rewind the stream and then deserialize as the other Foo... since they have
the same structure it might just work - not very efficient though...
Thanks you both, I'm trying to evaluate how much this option will cost in
term of performance (having to do this stuff to create some king of NLB
based on my application and having a performance hit for language reasons
seems a little nonsense).

Ciao
Massimo
Jul 5 '06 #4

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

Similar topics

3
2349
by: Sandy | last post by:
Hi, I have two files as folllows file1.cpp #include<iostream> using namespace std; namespace { void show(); void fun() { cout<<"fun called\n"; } }
5
10083
by: Alexis | last post by:
Hello, I have a set of classes I created from schema files using the xsd.exe tool. I'm using namespaces in the clases ( I had to because I have some classes with the same name but not the same class ) Here is how a given class wil looks like. <System.Xml.Serialization.XmlRootAttribute(:="mynamespace", IsNullable:=False)> _ Public Class ClassName
9
9028
by: Richard L Rosenheim | last post by:
I'm trying to query a XML file that was created via ADO.NET. My query wasn't returning anything, and I tracked the problem to an issue with the namespace that ADO.NET specified. When I remove the namespace from the XML data, the query worked. Okay, so I added code to create a XMLNamespaceManager and populate it with the namespace. Now, I'm getting this exception: Prefixes beginning with "xml" (regardless of whether the characters...
3
2351
by: Steven Fox | last post by:
============================================================ About DB2 Administration Tools Environment ============================================================ DB2 administration tools level: Product identifier SQL08015 Level identifier 02060106 Level DB2 v8.1.5.449 Build level s040212 PTF WR21334...
10
6663
by: anders | last post by:
I have 2 external assemblies A1 and A2 that both define class X in the global namespace. I need to use both assemblies in my VB project but the names X are ambiguous. How can I get around this problem? Is there a way to refer to the assembly, f.ex. A1.X and A2.X (this syntax does not compile). Or can I change the name X in the Imports directive? Again the problem is how do I refer to the 2 different X'es in assemblies A1 and A2:
2
2759
by: yqlu | last post by:
I hava developed a client in C# that is connected to a 3-party XML Web Services developed in Java based on the AXIS 1.1. Most methods call are successful except for one method named "findObjects" and return a complex type "FieldSearchResult". The error message as following : "Cannot assign object of type System.String to an object of type System.String. There is an error in XML document (23, 97)." By the way,I hava written a client in Java...
1
1464
by: Alex Maghen | last post by:
I've been using my installed VS 2005 for several months with no problem. Suddenly, something strange is happeneing and I'm not sure if it's something I'm missing in ASP.NET or something that's gotten messed up in VS. If I create a completely new Web Site Project in a blank directory with nothing in it, VS automatically creates a single Default.aspx with a code-behind page. If I go in and edite the Code-Behind and insert something like a...
0
2260
by: Sergio E. | last post by:
Hello, I have a problem with masterpages and forms security. I made a new Web site, in which I have my page of login like of beginning, a master page with only a sitemappath object in it, the file of map of the site, the web.config and another page to do tests.
0
1246
by: Sergio E. | last post by:
Hello, I have a problem with masterpages and forms security. I made a new Web site, in which I have my page login.aspx as the homepage , a master page with only a sitemappath object in it, the file of map of the site, the web.config and another page to do tests. In the page redirected from login there are a label and a combo (dropdown)
6
3254
by: praveenb000 | last post by:
we hosted a website http://vijayawadanalanda.org developed using asp.net and back end MS Accees database. There is some database connectivity problem occurring when saving the information in page url : http://vijayawadanalanda.org/feedback.aspx getting error: Not a valid file name. Please provide me solution to rectify this problem.
0
9636
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
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,...
0
10139
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9931
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7485
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
6727
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
5373
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
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.