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
LVL 1
DipehKhakhkharAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.