cancel
Showing results for 
Search instead for 
Did you mean: 

C# Web Service Proxy - Autogenerated Error

Former Member
0 Kudos

Hi all,

I'm trying to consume a SAP Webservice in a C# console application within Visual Studio 2005. I've added the web reference to the WSDL and as such Reference.cs has been automatically generated. My problem is that I'm receiving two different errors at multiple different locations within this file.


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

On the line System.Xml.Serialization.XmlElementAttribute(Form=_System_._Xml_.Schema.XmlSchemaForm.Unqualified) (Surrounded by square brackets, I'm not sure how to escape the hyperlink code), I'm receiving the following errors respectively:

System - An object reference is required for the nonstatic field, method, or property 'WSTest.dotnetWS.Bapiret2.System.get'

XML - 'string' does not contain a definition for 'Xml'

I'm not sure why, as this code has been automatically generated, that I'm receiving these errors, is there something that I need to change in order to rectify this problem?

Thanks,

Cal

Accepted Solutions (1)

Accepted Solutions (1)

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Cal,

is it maybe the error described in this thread ?

Best regards,

André

Former Member
0 Kudos

Thanks André, yes it was the same error.

While I wasn't able to solve the clash of the Bapiret2 field SYSTEM with the .NET keyword System, I negated the problem by creating my own structure with the fields I needed (did not need the system field).

So now my program compiles and runs, however - when I try to use the program, that is; i try to invoke the function module the WS is connected to, I receive the following error:

System.InvalidOperationException: Namespace prefix ' SOAP-ENV' not defined
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadFaultCode(XmlReader reader)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadSoapException(XmlReader reader)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at WSWinApp.dotnetWebService.service.ZcalGetPdets2(ZcalGetPdets2 ZcalGetPdets21) 

My understanding of SOAP isn't that great but my first idea is that I think the WSDL may need a <SOAP-ENV:Envelope /> tag somewhere, although that's just a guess.

If anyone could shed some light on how to solve this problem or even where to look it would be greatly appreciated.

Thanks in advance.

Cal

Former Member
0 Kudos

Update: I'm not exactly sure what was causing the above error but the problem seemed to be solved once I fixed a problem in the Function Module that the WS was calling.

Answers (1)

Answers (1)

rima-sirich
Advisor
Advisor
0 Kudos

Hi Cal,

Did you add a reference manually or by using ES Explorer for .NET ?

Regards,

Rima.

Former Member
0 Kudos

Hi Rima,

I'm not sure what you mean by ES Explorer, I added the reference by adding a web reference from the References-rightclick menu.

Although I did try yesterday to run wsdl.exe on the WSDL url which gave me a .cs file. However when I tried to compile this file via 'csc /target:library, i received the same errors in the console window.

Thanks,

Cal

rima-sirich
Advisor
Advisor
0 Kudos

Hi Cal,

I would suggest you to evaluate [SAP ES Explorer for Microsoft .NET.|https://www.sdn.sap.com/irj/sdn/dotnet?rid=/library/uuid/10cacdca-b0bb-2a10-77be-d600de4658b7] It helps you to consume Enterprise Services that are available in SAP Services Registry. You can read about the tool [here.|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c0319dc4-d76d-2a10-d19f-e4f4ff315bde]

If you are still interested in manual process, you may find some parts of this [article|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/905c28e4-38a9-2910-4db5-d39e4fcbf78b] helpful ( like renaming "parameters" to "parameter" ).

Regards,

Rima.

Former Member
0 Kudos

Hi Rima,

Thanks for you help, however the general consensus here is that we want to be able to add the Web Service 'manually', that is - adding the Web Service via WSDL into VS.net (2005) directly. As such I need to get around the original problem of the compiler errors found within the Reference.cs file (original post). Do you have any ideas on what may be causing this problem or how to get around it?

Thanks,

Cal