views:

2732

answers:

4

We have consumed a third party web service and are trying to invoke it from an ASP.NET web application. However when I instantiate the web service the following System.InvalidOperationException exception is thrown:

Method 'ABC.XYZ' can not be reflected. System.InvalidOperationException: Method 'ABC.XYZ' can not be reflected. ---> System.InvalidOperationException: The XML element 'MyDoc' from namespace 'http://mysoftware.com/ns' references a method and a type. Change the method's message name using WebMethodAttribute or change the type's root element using the XmlRootAttribute.

From what I can gather there appears to be some ambiguity between a method and a type in the web service. Can anyone clarify the probably cause of this exception and is there anything I can do to rectify this or should I just go to the web service owners to rectify?

Edit: Visual Studio 2008 has created the proxy class. Unfortunately I can't provide a link to the wsdl as it is a web service for a locally installed thrid party app.

+1  A: 

I'm guessing the wsdl emitted by or supplied with the service is not in a form that wsdl.exe or serviceutil can understand - can you post the wsdl or link to it?

how are you creating the proxy classes?

Also you might like to try and validate the wsdl against the wsdl schema to check its valid

Richard
+1  A: 

I have come across the exact same problem when I was consuming a 3rd party web service. The problem in this instance was that the mustUndertand property in the reference file was looking for a Boolean, whereby the namespace property looked for a string.

By looking through the reference i was able to idenitfy the offending property and simply add "overrides" to the method signature.

Not ideal as any time you update the service you have to do this but I couldn't find any other way around this.

To find the reference file select "all files" from the solution explorer

Hope this helps

Dean
A: 

It seems the problem is down to data type issues between VS and the web service that was written in Java.

Ultimately it was fixed by manually editing the class and schema files that were created by VS.

Andy Rose
A: 

I got the same message but mine was caused by a missing System.Runtime.Serialization.dll since I tried to run a 3.5 application on a machine with only .NET 2.0 installed.

Gerrie Schenck