Tobias Schittkowski Tobias Schittkowski - 1 month ago 16
C# Question

InvalidOperationException when SOAP webservice - but working on dev machine

I have a webservice class which inherits from

SoapHttpClientProtocol


[WebServiceBinding(Name = "gp_ws_mySoap", Namespace = "https://www.xxx/yyy/")]
internal class WebserviceNestle : SoapHttpClientProtocol
{
public WebserviceNestle(string sUrl) : base()
{
Url = sUrl;
}

[SoapDocumentMethod("https://www.xxx/yyy/test",
RequestNamespace = "https://www.xxx/yyy/",
ResponseNamespace = "https://www.xxx/yyy/",
Use = SoapBindingUse.Literal,
ParameterStyle = SoapParameterStyle.Wrapped)]
public XmlNode test(string a, int b)
{
var results = Invoke("test", new object[] {
a,
b
});
return (XmlNode)results[0];
}
}


On my development machine, the webservice call works, however on production, I get the exception "
System.InvalidOperationException
: The XML element named '' from namespace" from namespace is already present in the current scope:

The stacktrace of the exception is:


System.InvalidOperationException: Die
?????????????????????????????????????????.?????????????????????????????????????????-Methode
kann nicht reflektiert werden. ---> System.InvalidOperationException:
Fehler beim Reflektieren von ''. --->
System.InvalidOperationException: Das XML-Attribut '' im Namespace
'https://www.yyy/xxx/' ist bereits im aktuellen Bereich
vorhanden. Verwenden Sie XML-Attribute, um einen anderen XML-Namen
oder -Namespace f├╝r das Element anzugeben.
bei System.Xml.Serialization.XmlReflectionImporter.AddUniqueAccessor(INameScope
scope, Accessor accessor)
bei System.Xml.Serialization.XmlReflectionImporter.AddUniqueAccessor(MemberMapping
member, INameScope elements, INameScope attributes, Boolean
isSequence)
bei System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[]
xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean
rpc, Boolean openModel, RecursionLimiter limiter) --- Ende der
internen Ausnahmestapel├╝berwachung ---
bei System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[]
xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean
rpc, Boolean openModel, RecursionLimiter limiter) bei
System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(String
elementName, String ns, XmlReflectionMember[] members, Boolean
hasWrapperElement, Boolean rpc, Boolean openModel, XmlMappingAccess
access)
bei System.Web.Services.Protocols.SoapReflector.ImportMembersMapping(XmlReflectionImporter
xmlImporter, SoapReflectionImporter soapImporter, Boolean
serviceDefaultIsEncoded, Boolean rpc, SoapBindingUse use,
SoapParameterStyle paramStyle, String elementName, String
elementNamespace, Boolean nsIsDefault, XmlReflectionMember[] members,
Boolean validate, Boolean openModel, String key, Boolean writeAccess)
bei System.Web.Services.Protocols.SoapReflector.ReflectMethod(LogicalMethodInfo
methodInfo, Boolean client, XmlReflectionImporter xmlImporter,
SoapReflectionImporter soapImporter, String defaultNs)

Answer

I found the problem:

I used Confuser (https://yck1509.github.io/ConfuserEx/) to protect the application, this caused the reflection error in the SoapHttpClientProtocol parent class constructor.