Question

i have a .net issue when im trying to consume SAP ws , the element system cusing this error

  error CS0120: An object reference is required for the nonstatic field, method, or property 'Bapiret2.System'

their is a solution as described here BUT im want to find a solution that doesn't required to change the WSDL

http://www.drowningintechnicaldebt.com/ShawnWeisfeld/archive/2009/04/17/system-namespace-conflict-in-sap-web-services.aspx

or this one , http://ddkonline.blogspot.com/2009/09/sap-to-microsoft-net-integration-fixes.html

do you have any experience with that and how you solve it?

thanks miki

Was it helpful?

Solution

The problem is because System namespace in both Windows and BAPI. This can be dealt with by adding global:: before all calls giving the above errors. This does not involve editing WSDL.

References: Comment on one of the page you mentioned above and link that comment referred to.

OTHER TIPS

Since this issue is caused by naming conflict in .NET and SAP, another workaround for this issue without changing SAP configuration:

Add an alias for System.XML as below in Reference.cs

using SysXml = System.Xml;

Then, replace all the System.Xml where report the error with "SysXml" as below (please note that the word "SysXml" is originally "System.Xml" after adding the service, which caused this issue)

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=SysXml.Schema.XmlSchemaForm.Unqualified)]
public string Type {
    get {
        return this.typeField;

    set {
        this.typeField = value;
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top