1
votes

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)

2
it's hard for me to read your stack trace, please change your machine language to English, It's German now - Imran Shamszadeh
Is there a way for you to capture the soap envelope with the actual XML content in both cases? It would be interesting to see the differences in dev and production. Thanks. - Lefty G Balogh
The question marks are in your stacktrace as well? - Jongware
Your stack trace seems read as "unable to reflect method - use XML attributes to specify another XML name or namespace for the element". It related to an XML file passed to the method for reflection, show the XML content if necessary (also please translate the stack trace for anyone who can't read German). - Tetsuya Yamamoto
You might want to check the InnerException property after catching this exception to find out what the actual problem is.. - A.J.Bauer

2 Answers

2
votes

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.

1
votes

My guess works if you don't use an object XML serializer.

So, what if one of your attributes must contain a free string value and is not XML-encoded. If it contains same quotation chars as XML builder uses to quot attribute values, then you could receive something like an XML injection.

For instance, you have to pass a string [That's what I call "a real problem"]. If you don't XML-encode the string you are going to have something like which means that attribute value is closed before [a] char and everything from [a] and to the right becomes XML instructions which I don't expect a normal XML parser to understand.

If you use XML-encoded values, you would receive (if you have " and ' entities defined or their codes otherwise) which is a well-formed XML.

Try using SoapUI (they have a free community edition) to analyze the service response.