• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

Migrating web service client from .NET 1.1 to .NET 2.0

I am migrating my web service client from .NET 1.1 to .NET 2.0 [Well I know I am little late in this but as said don't change if its working]. Migrating .sln and .vcproj file was piece of cake and everything compiler properly as well.

But it started giving problem during runtime and the reason was I have created my own types in 1.1 and these are not conflicting with types in 2.0.

For example:

ArrayOfString
ArrayOfInt and so on.

.NET 2.0 provides the same name for these types and it is now conflicting and throwing reflection error and eventually boiling down to this error message

One solution is to change my type names i.e. from ArrayOfString to XXXArrayOfString but this will require to change all the users of my web services which is not a good solution.

I have looked at this article but of no use

http://social.msdn.microsoft.com/forums/en-US/asmxandxml/thread/abba7508-b126-4c6e-9735-c3ae9e57b64a/

I guess, there should be some simple solution to deal with this. I would appreciate if you please inform me how to go about it.

Dipesh
0
DipehKhakhkhar
Asked:
DipehKhakhkhar
  • 3
  • 2
1 Solution
 
Tony McCreathTechnical SEO ConsultantCommented:
I presume you can change your internal naming, but you need to keep the webservice interfaces the same

Are you using the ArrayOfString class as a property in a webservice method?

Hence, you cannot change it as it serialises to xml as you have defined?

Could you change its class name but use attributres to make it render xml as before?
0
 
DipehKhakhkharAuthor Commented:
Thanks for the reply.

So if i have the following type i.e.

      <xsd:complexType name="ArrayOfString">
            <xsd:sequence>
                  <xsd:element name="String" type="xsd:string" maxOccurs="unbounded" minOccurs="0"/>
            </xsd:sequence>
      </xsd:complexType>

Yes this type is used by many of other complex types i.e. for example

<xsd:complexType name="ResultSetData">
                        <xsd:sequence>
                              <xsd:element name="ColNames" type="typens:ArrayOfString"/>
                              <xsd:element name="RowCount" type="xsd:int" minOccurs="0"/>
                              <xsd:element name="EndOfRS" type="xsd:boolean" minOccurs="0"/>
                              <xsd:element name="Cursor" type="xsd:int" minOccurs="0"/>
                        </xsd:sequence>
</xsd:complexType>

Similarly it is used in other complex types which are part of my web service method.

I didn't get what do you mean by this statement
"Could you change its class name but use attributres to make it render xml as before?"

Considering above example how will i do it?


0
 
Tony McCreathTechnical SEO ConsultantCommented:
You can apply attributes to your class and properties to specify how they get serialised to Xml. I was wondering if one of these could be used to make a class serialise as "ArrayOfString" when its actual class name is different.

Maybe this would work...

[XmlRoot(ElementName = "ArrayOfString")]
public class MyArrayOfString
{
 ...
}
0
 
DipehKhakhkharAuthor Commented:
Thanks again for replying.

The following change
/**
*
[XmlRoot(ElementName = "ArrayOfString")]
public class MyArrayOfString
{
 ...
}
*/

involves changing the Name of the class. As soon as I do that I am able to get rid of that error. But as i said I have many such instances (class and ArrayOfClass) and then it gives me error there.

Further, can I change my xsd to reflect this rather than manually changing reference.cs file because this seems to be never ending process.

I have compared reference.cs file generated using VS2003 and VS2008 and both are drastically different.

I am not sure writing a new client will be better option because it is complaining in generated code as well.


0
 
DipehKhakhkharAuthor Commented:
I have tried other options and eventually nothing helped.

As I have mentioned in my query post that only solution for this is to change the name of the type (which is the last thing I want to do ).

Administrator,
I will accept this post as my solution.

Thanks!
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now