cancel
Showing results for 
Search instead for 
Did you mean: 

Handling Errors When Calling SAP Web Service From ASP.NET

0 Kudos

We are just starting on our initial round of testing of calling an SAP web service that we have created from a ASP.NET web page. We are calling the web service fine (using VB.NET 2005) and when everything processes ok on the SAP end we get the data back that we would expect.

The problem we are having is that if we end us passing something to the SAP web service that the ECC side does not like it dumps to the screen and does not gracefully return back a BAPI Error object for us to unpack on the .NET side to determine what the error was that caused the dump. We can mask the problem from the user by using the Try Catch error handling in ASP.NET but ideally we would like to be able to get the BAPI Return object back so that we can read it and determine what happened in the SAP processing of the request.

Is this somthing that we need to fix on the ASP.NET side or the way that the processing is happening on the SAP side so that we can correctly get the BAPI Return object that we want during an error condition?

Versions:

ERP 2005

ECC 6.0

Portal NW2004s or NW7

Java SPS 10

Thanks,

Derek

Message was edited by:

Derek Feagin

Message was edited by:

Derek Feagin

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Derek,

this error you get because of the word "System" in the WSDL from SAP, .NET interprets this as the object System. The best way to avoid this problem is opening the WSDL from SAP and replace all "System" with "SYSTEM". Let us knwo whether this works.

- Juergen

Former Member
0 Kudos

Hi Juergen,

I'm getting the same errors as Derek. I've noticed that the errors are only in the get and set methods of the Bapiret2 class.

I tried to replace the word 'System' with 'SYSTEM' in places where the aforementioned error is highlighted, however this then gives me the error 'The name 'SYSTEM' does not exist in the current context'.

Am I missing something here?

Thanks in advance,

Cal

UPDATE:

After re-reading your post I think I understand the nature of the problem being the System field within Bapiret2 that's causing the clash (please correct me if this is not the case), does this then mean the alteration to upper case 'SYSTEM' fix is within the original ABAP to which my SAP WS is trying to talk to?

Edited by: Cal Loudon on Oct 2, 2008 5:19 AM

Former Member
0 Kudos

Thanks Juergen, your question helped me get past the compilation error.

I just went in and created an alias for "System.XML" by specifying :

using SysXml = System.Xml; in the Reference.cs file.

Then I went in and changed where it wouldnt compile to say:

[System.Xml.Serialization.XmlElementAttribute(Form = SysXml.Schema.XmlSchemaForm.Unqualified)]

instead...

That got me past the compilation error, but now I a getting a "Deserialisation failed" message instead... but that's probably a whole other story:(

Former Member
0 Kudos

Hi Cal Loudon,

Jurgen said in the WSDL from SAP and replace all "System" with "SYSTEM", not in visual studio 200X.

you can go to se80, choose the local object and you can see enterprise service, and choose the definit which is you publish, then you can see the Types on right.

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Derek,

in the following blog I have described .

.

Best regards,

André

0 Kudos

I will review those articles. Thanks!

Also I was wondering if we create a web service on the SAP side with a BAPRET2 as the error object coming back - when I add the web reference to my .net project and try to compile after adding it the comilation fails. If started from a <b>Web Application Project</b> I get these errors (14 of them):

Error 1 Reference to a non-shared member requires an object reference. C:\Projects\BapiReturn\BapiReturn\Web References\WSTest\Reference.vb 160 10 BapiReturn

if I started from a <b>WebSite project</b> I get these errors (28 of them):

Error 1 An object reference is required for the nonstatic field, method, or property 'WSTest.Bapiret2.System.get' c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\bapireturn\10e73389\c68b05f3\App_WebReferences.msrec2vu.0.cs

Error 2 'string' does not contain a definition for 'Xml' c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\bapireturn\10e73389\c68b05f3\App_WebReferences.msrec2vu.0.cs

Error 3 An object reference is required for the nonstatic field, method, or property 'WSTest.Bapiret2.System.get' c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\bapireturn\10e73389\c68b05f3\App_WebReferences.msrec2vu.0.cs

Error 4 'string' does not contain a definition for 'Xml' c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\bapireturn\10e73389\c68b05f3\App_WebReferences.msrec2vu.0.cs

Error 5 An object reference is required for the nonstatic field, method, or property 'WSTest.Bapiret2.System.get' c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\bapireturn\10e73389\c68b05f3\App_WebReferences.msrec2vu.0.cs

Error 6 'string' does not contain a definition for 'Xml' c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\bapireturn\10e73389\c68b05f3\App_WebReferences.msrec2vu.0.cs

are these errors expected or do I need to make adjustments to the WSDL that the SAP system generates or what is going on here??

Thanks again,

Derek

Former Member
0 Kudos

@Andre Fischer What have you described? where is the link????

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Imir,

I am not 100% sure anymore since it this post is already 6 years old ...

But I remember that I did a post around the handling of BAPIRETURN in .NET code here:

http://scn.sap.com/people/andre.fischer/blog/2007/02/07/exception-handling-for-web-services-based-on...

Hope this helps,

Andre