Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web services: method cannot be reflected exception

When trying to create an instance of a service, I'm getting a

"Method cannot be reflected"

exception. Digging deeper down in the inner exceptions reveals:

"Types 'WebServiceClient.com.compamy.string1' and 'WebServiceClient.com.company.string' both use the XML type name, 'string', from namespace 'http://www.w3.org/2001/XMLSchema'. Use XML attributes to specify a unique XML name and/or namespace for the type."

What does the damn thing want from me? It is code auto generated by VS2010...why do I have to fiddle with it?

Here are the two types:

[GeneratedCode( "System.Xml", "4.0.30319.233" )]
[Serializable]
[DebuggerStepThrough]
[DesignerCategory("code")]
[XmlType(TypeName = "string", Namespace = "http://www.w3.org/2001/XMLSchema")]
[XmlRoot("FileName", Namespace = "http://company.com/api3/Content/Download/", IsNullable = true)]
public partial class string1 : SoapHeader

and

[GeneratedCode("System.Xml", "4.0.30319.233" )]
[Serializable]
[DebuggerStepThrougt]
[DesignerCategory("code")]
[XmlTypeAttribute(Namespace = "http://www.w3.org/2001/XMLSchema")]
[XmlRootAttribute("SessionKey", Namespace = "ns", IsNullable = true)]
public partial class @string : SoapHeader
like image 430
Krumelur Avatar asked Feb 15 '12 13:02

Krumelur


1 Answers

I found a solution but I cannot explain why it is working. I simply removed all the type mapping attributes from all methods and I don't get any more errors.

Lines removed:

[XmlType(TypeName = "string", Namespace = "http://www.w3.org/2001/XMLSchema")]

If somebody can explain I would really appreciate it!

like image 187
Krumelur Avatar answered Nov 10 '22 07:11

Krumelur