Last post Nov 11, 2015 01:42 AM by DaveSemm
Nov 10, 2015 09:44 AM|DaveSemm|LINK
I wrote a web service in Visual Studio 2005 about 10 years ago, and have been adding to it ever since. (This is a hand-coded service, i.e. not using WCF.) I migrated it to VS2008 then 2012 over the years. Clients applications connect to it using a Web Reference,
not a Service Reference. I considered changing that some day, but the web service is huge and I usually only get a short time to add new features; no one is interested in me re-writing it. There are a dozen different client applications including web sites,
desktop apps, Windows services and other web services.
This morning I needed to add a new item to the SOAP interface, so I had to update the web reference - new features don't always require a change to the interface, so I haven't refreshed it for a while. The solution (which includes the web service and all
the clients) compiled ok, but when I run any client, it fails to instantiate the web service reference class, with the error message "There was an error reflecting type ..." I removed my changes so the code is exactly what was running earlier today, but it
still fails. So far as I can tell, something about updating the web reference has gone wrong.
Many people on the support forums say that we shouldn't be using Web References anymore, and suggested that that could be the problem. So I made a quick test client using a Service Reference, and sure enough, this works! My problem is I do not have time
to rewrite all the clients - it could take me months, and I normally have less than a week to make any change.
So, has something broken in Web References? How can I debug the issue with the Web Reference? Am I required to replace Web references with Service References? Or can I do something to make it work?
Nov 10, 2015 12:01 PM|mgebhard|LINK
Do you have an inner exception? What type is not serializing properly?
Nov 11, 2015 01:42 AM|DaveSemm|LINK
Although it was compiling without errors, I went back and checked the warnings, and found it complaining about about "namespace" being both a class name and a property of the class in the Reference.vb code, which is generated by the Web References wizard.
(I hope this is not an issue, but the clients are in VB.net, and the server is in C#.)
I abbreviate the SOAP namespace names to make the requests and responses shorter and more readable, using code like this:
partial class MyFuncResp
public XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();
This appears to be confusing the Web Reference wizard. By removing this code, it now works ok, but of course now the responses are long and unreadable. The Web Reference wizard did not have a problem with this in the past. The Service Reference wizard did
not have a problem, so it looks like I am being forced to switch to it for future development.
One easy change I will have to try is to migrate the code to VS 2015. I am using VS2015 for new projects, so it shouldn't be a big issue, assuming it compiles.