cancel
Showing results for 
Search instead for 
Did you mean: 

Exception: "Method xyz can not be reflected." in .Net Connector 2.0

Former Member
0 Kudos

Hi,

I have generated a proxy class with two RFC's. The first RFC has a table parameter with the same name and type as an export parameter of the second RFC.

When I create an object of the proxy class with "SAPProxy sap = new SAPProxy();" I get an exception "Method SAPProxy.Z_Rfc_Aenr_Suchen_Via_Ccart can not be reflected." where "Z_Rfc_Aenr_Suchen_Via_Ccart" is the name of the first RFC and the following inner exception

"The XML element named 'AENR_--5fRFC' from namespace '' references distinct types ZAENR_RFC and ZAENR_RFCTable. Use XML attributes to specify another XML name or namespace for the element or types.".

The generated code for the parameter of the first RFC is:

[RfcParameter(AbapName = "AENR_RFC",RfcType=RFCTYPE.RFCTYPE_ITAB, Optional = false, Direction = RFCINOUT.INOUT)]

[XmlArray("AENR_--5fRFC", IsNullable=false, Namespace="")]

[XmlArrayItem("item", IsNullable=false)]

ref ZAENR_RFCTable Aenr_Rfc)

and for the second RFC:

[RfcParameter(AbapName = "AENR_RFC",RfcType=RFCTYPE.RFCTYPE_STRUCTURE, Optional = true, Direction = RFCINOUT.OUT)]

[XmlElement("AENR_--5fRFC", IsNullable=false, Namespace="")]

out ZAENR_RFC Aenr_Rfc)

now when I change one of the XML Names from "AENR_5fRFC" to "AENR_5fRFC1" in the generated proxy class, the proxy class instantiates correctly, but that should not be the solution.

Is this a bug in .Net Connector 2.0? In Version 1 I didn't get this exception although the parameters where generated with the same name "AENR_RFC" (not "AENR_--5fRFC")

Thanks!

Markus

Accepted Solutions (1)

Accepted Solutions (1)

reiner_hille-doering
Active Contributor
0 Kudos

Yes, sorry again a bug.

I was fixing a special case where you have strange characters in ABAP names that are not supported in XML and forgot "_" which is an allowed char.

In the moment you can fix it by replacing "_--5f" with "_", which should be perfectly Ok.

I'll try posting a fix soon.

Former Member
0 Kudos

Would this bug fix be a integrated in the SAP.NET Connector 2.0 (final)? Or would be a hotfix/patch that client need to install? Thanks for the support.

reiner_hille-doering
Active Contributor
0 Kudos

A fix for the problem is now available in OSS / SAP Service Marketplace note 506603. As the note is maintained in german, it might need time until the english version is up-to-date. In the meantime just open the german version of the note, take the attached ZIP files and extract it to your "%program files%\Microsoft Visual Studio .NET 2003\Common7\IDE" directory.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

when comparing the proxy classes generated with NCO 1 and version 2, I found the difference that probably causes the problem.

Each parameter of a RFM in Version 2 is marked with [XmlElement("XYZ", IsNullable=false, Namespace="")]. In the proxy class generated with version 1 "Namespace="" " is missing.

Removing the Namespace property solves the problem. Under some circumstances the Namespace property in combination with my special RFM's - parameter obviously causes the reflection problem.

What is the difference between setting the Namespace to "" and omitting it?

Thanks!

Markus

reiner_hille-doering
Active Contributor
0 Kudos

We did some analysizis on the problem and here's the result:

SAP's Soap processor expects and sends all XML that is in a message without XML namespace - except the basic function request and response elements. In older version it was different - all elements where qualified by a namespace.

To consider the changed behavior we decided to generated a 'Namespace=""' attribute on all parameters.

Now we learned that Microsoft's WebServiceClient seems to create all parameters in a common class (or whatever), so that parameters with same XML element, but different types cause an exception. In fact it's a MS bug.

Fortunately there is a different way to force the MS webservice client to render and parse the inner XML unqualified using the "Form=System.Xml.Schema.XmlSchemaForm.Unqualified" attribute. Seems that this doesn't have the negative effect. I will change the proxy generator accordingly. Please stay tuned.

Former Member
0 Kudos

Do you mean replacing all occurances of Namespace="" by

Form=System.Xml.Schema.XmlSchemaForm.Unqualified?

I did it manually. First it seemed to work, but then I discovered a problem in another project.

There I have a proxy class with the RFM BAPI_TRANSACTION_COMMIT, where I get the exception "Method SAPClient.CommitWork can not be reflected". Obviously BAPI_TRANSACTION_COMMIT is called and used internally in NCO in Method SAPClient.CommitWork.

The solution is to call CommitWork rather than generating and calling BAPI_TRANSACTION_COMMIT in my own proxy class.

What other RFM are used internally in NCO?

BAPI_TRANSACTION_COMMIT, BAPI_TRANSACTION_ROLLBACK ...

Perhaps all these NCO internal RFM must also have the Form=System.Xml.Schema.XmlSchemaForm.Unqualified attribute.

Former Member
0 Kudos

Hello,

Internally, SAPClient.CommitWork and SAPClient.Rollback use BAPI_TRANSACTION_COMMIT and BAPI_TRANSACTION_ROLLBACK respectively. So you never need to add these two function modules when you generating your proxy.

Admittedly, it would be ideal if the wizard could filter out these functions from the list.

Regards,

Guangwei

Former Member
0 Kudos

I got this error message "Method SAPClient.Commitwork can not be reflected."

I extracted the dll file from note 506603, but still not work.

Is it possible to call CommitWork and WAIT rather than generating and calling BAPI_TRANSACTION_COMMIT in my own proxy class?

Thanks,

Khuong Dang

reiner_hille-doering
Active Contributor
0 Kudos

CommitAndWait is INTENTIONALLY disabled in NCo, because it can - wrongly used - cause deadlocks that bring your SAP system in an unusable state.

If you are sure you need it, you can define your own ABAP that calls BAPI_TRANSACTION_COMMIT with Wait and expose this to NCo.

Former Member
0 Kudos

Hello Reiner,

that explains the strange XML-Names, but it didn't solve my problem. When changing the xml name of one parameter to a unique name it works, but in NCO 1 it worked without changing the name.

Markus