By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,602 Members | 1,507 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,602 IT Pros & Developers. It's quick & easy.

wsdl2java namespace mapping option equivilent in .net

P: n/a
Hi,

I am working on a project which has a wsdl file which contains two elements
(lets call then the Name element) with same name but under different
targetNamespaces. When I generate the client proxy file I end up with two
..NET classes, one called Name and the other called Name1. The Name1 class
has the appropriate attributes to serialise the content to an element called
name with the correct xml namespace.

The wsdl2java tool that ships with axis allows you to specify a
targetNamespace to java package mapping file that will cope with duplicate
element names in a wsdl document, allowing you to generate java classes that
have a unique namespace scope in the appropriate package (axis will also try
to magically work out the package name from the targetNamespace if no mapping
file exists).

I'm wondering if anyone has any thoughts on how to cope with this scenario
in .net, I really don't want to have to use the client proxy with a Name
class and a Name1 class but there does not seem to be an easy way using
wsdl.exe to get the correct classes generated.

Cheers,

Colin
Dec 1 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
DC
You're right, I don't think there is an easy way to get Wsdl.exe to do this
in .NET 1.1.
You can always post-process the generated code.
For example, use sed.exe to modify the Name1 class, or drop it into a
different namespace Xxxx{ } scope.

If you are using .NET 2.0, which was released publicly on 7 November, there
is a SchemaImporterExtension mechanism that allows you to define the way
..NET maps XML types to .NET types. What you do is define a small class that
derives from SchemaImporterExtension, which does the mapping dynamically.

Your code receives the namespace and typename from the schema, and must
return the .NET typename. It could do something like:

if ((namespace == "urn:myNamespace1") && (typename=="Foo")) {
return typeof(MyFooType).FullName; // could also return immediate string
eg "com.nehru.Foo"
}
else if ((namespace == "urn:DifferentNamespace") && (typename=="Foo")) {
return typeof(MyDifferentType).FullName; // could also return immediate
string eg "MyCompany.AnotherType"
}

For more on this extension point, see
http://msdn2.microsoft.com/en-us/lib...US,VS.80).aspx

-Dino


"ripster" <ri*****@discussions.microsoft.com> wrote in message
news:56**********************************@microsof t.com...
Hi,

I am working on a project which has a wsdl file which contains two
elements
(lets call then the Name element) with same name but under different
targetNamespaces. When I generate the client proxy file I end up with two
.NET classes, one called Name and the other called Name1. The Name1 class
has the appropriate attributes to serialise the content to an element
called
name with the correct xml namespace.

The wsdl2java tool that ships with axis allows you to specify a
targetNamespace to java package mapping file that will cope with duplicate
element names in a wsdl document, allowing you to generate java classes
that
have a unique namespace scope in the appropriate package (axis will also
try
to magically work out the package name from the targetNamespace if no
mapping
file exists).

I'm wondering if anyone has any thoughts on how to cope with this scenario
in .net, I really don't want to have to use the client proxy with a Name
class and a Name1 class but there does not seem to be an easy way using
wsdl.exe to get the correct classes generated.

Cheers,

Colin

Dec 2 '05 #2

P: n/a
Dino,

Thanks for the information, maybe I'll convince the boss to upgrade to .NET
2.0 :-)

Cheers,

Colin

"DC" wrote:

For more on this extension point, see
http://msdn2.microsoft.com/en-us/lib...US,VS.80).aspx

-Dino


Dec 2 '05 #3

P: n/a
Just one further note for anyone else, it looks like the svcutil.exe tool
that ships with WCF will have a command line option that will allow mapping
xml namespaces to .net namespaces.

Cheers,

Colin

"DC" wrote:
You're right, I don't think there is an easy way to get Wsdl.exe to do this
in .NET 1.1.


Dec 3 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.