cancel
Showing results for 
Search instead for 
Did you mean: 

calling a sap webas 6.20 web service from .net

Former Member
0 Kudos

I was able to call the rfc bapi in the form of web service from a soap client

where the post data is something like this:

<b><?xml version="1.0" encoding="UTF-8"?>

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

<SOAP-ENV:Body>

<rfc:BAPI_BUPA_ADDRESS_GETDETAIL xmlns:rfc="urn:sap-com:document:sap:rfc:functions">

<BUSINESSPARTNER>0000000232</BUSINESSPARTNER>

<ADDRESSGUID></ADDRESSGUID>

</rfc:BAPI_BUPA_ADDRESS_GETDETAIL>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope></b>

and the url was:

<b>http://<server-name>:8000/sap/bc/soap/rfc</b>and I am getting the response from the bapi.

I am not sure how will I call this web service from .net, I mean how will i pass the login information and the post data.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I tried the way u told, and went thru the document

I added the .wsdl file as a web reference. IF I compile ,it is giving me an error

<b>Reference to a non-shared member requires an object reference.</b>

It is pointing to references.vb which is generated by .net when we add a web reference.

The wierd part is errors only pertain to section where bapiret2 class is implemented. I tried out with a couple of bapis, it is the same error in the code generated by .net when web reference is added.

I am able to view the wsdl in browser using the url.

I tried in both vs2003 as well as vs 205 , thinking that it may be a 2005 issue.

Any ideas.....

reiner_hille-doering
Active Contributor
0 Kudos

This is just an issue on name clash between VB keywords or Microsoft namespaces/classes with structure fields. Unfortunately the MS proxy generator doesn't have an automatic or manual feature for renaming these fields. So you need to rename them by hand in the generated proxy. A typical candidate is the field/property "System". It clashes with the corresponding "System" namespace. Change the field/property name and necessarily add or change the XMLElement / XMLAttribute attributes so that the WSDL contract remains the same.

Former Member
0 Kudos

Thanks again!! I renamed SYSTEM property to System1 and it compiled. But where should i change the xml element/xml attribute to have the wsdl contract same.I assume I would have to change that in SAP.But I am not sure how...

reiner_hille-doering
Active Contributor
0 Kudos

No, you don't need to change it in SAP - and especially for standard structures like BAPIRET* you really shouldn't .

In the proxy you should see an

<XMLElementAttribute(...)> or <XMLAttributeAttribute(...)> (for VB)

or

[XMLElementAttribute(...)] or [XMLAttributeAttribute(...)] (for CS).

It could like this

[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string SYSTEM {
            get {
                return this.systemField;
            }
            set {
                this.systemField = value;
            }
        }

Change it to

[System.Xml.Serialization.XmlElementAttribute("SYSTEM", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string System_Renamed {
            get {
                return this.systemField;
            }
            set {
                this.systemField = value;
            }
        }

You see that the original name "SYSTEM" now appears as argument to the XMLElementAttribute. This let the .NET Runtime know that is still should use a tag named "SYSTEM" for it.

Former Member
0 Kudos

I am able to run it and get the result. But all the By Ref parameters passed to the web service return nothing including the BAPIRET2 table.

I have declared all the byref parameters as following:

Dim BAPIRET2() As svc.BAPIRET2 = Nothing

and the result as

Dim result As New svc.BAPIBUS1006_ADDRESS

when i call the web service, I am able to get the result, but not anything in byref parameters. They all return nothing , even though in SAP when i execute this bapi, it is returning these tables with values. In case of error also, BAPIRET2 Table returns nothing.

Is there anything else, I should be doing...

reiner_hille-doering
Active Contributor
0 Kudos

Also declare the ByRef parameter (all tables including BAPIRET2) with

Dim BAPIRET2() As new svc.BAPIRET2(0)

(sorry if the VB systaxt to create an empty array is wrong, as I'm not so good in VB).

Former Member
0 Kudos

IT worked.

I Used

Dim BAPIRET2() As svc.BAPIRET2 = {New svc.BAPIRET2()}

and it worked fine after that.

One other question. Is there a way to expose custom bapis

as webservices , so that they can be called from .net

thnks

reiner_hille-doering
Active Contributor
0 Kudos

> One other question. Is there a way to expose custom

> bapis

> as webservices , so that they can be called from

> .net

The Soap Processor in 6.20 exposes any RFC enabled function module as WebService. So just set the "RFC enabled" flag for your RFC/BAPI.

In 6.40 (NetWeaver 2004) and newer, you use instead the Web Service Creation Wizard that allows you to define a Web Service from any Function Module (RFC enabled or not, this doesn't matter).

Former Member
0 Kudos

I have tried the below changes but my code didnt work. Proxy code dont have the Get and Set Properties <System.Xml.Serialization.XmlElementAttribute("SYSTEM", Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _

Public SYSTEM1 As String

Former Member
0 Kudos

Recieved "Reference to a non-shared member requires an object reference" error. I have renamed the SYSTEM property to System1 and made the changes in the XML element in the proxy class as suggested in this forum but still not able to run the code. However, my proxy class doesn't have Get and Set methods as default.Any ideas....

Default code:

<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _

Public SYSTEM As String

Modified code as suggested:

<System.Xml.Serialization.XmlElementAttribute("SYSTEM", Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _

Public Property SYSTEM1() As String

Get

Return Me.SYSTEM1

End Get

Set(ByVal Value As String)

Me.SYSTEM1 = Value

End Set

End Property

Recieved the below Error:

"System.Xml.XmlException: The XML declaration is unexpected. Line 1, position 5.

at System.Xml.XmlTextReader.ParseTag()

at System.Xml.XmlTextReader.ParseRoot()

at System.Xml.XmlTextReader.Read()

at System.Xml.XmlReader.MoveToContent()

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 AAEWS.sa.com.aramco.onyx.ZAAE_TRIGGER_WORKFLOWService.ZAAE_TRIGGER_WORKFLOW(String I_APRCRITERIA, String I_BUKRS, String I_INITIATOR, String I_OBJECTID, String I_PROCID, String I_REQUESTOR, String I_SYSID, String I_URL, String I_WI_TEXT) in C:\VB\AAEWS\Web References\sa.com.aramco.onyx\Reference.vb:line 42

at AAEWS.Module1.Main() in C:\VB\AAEWS\Module1.vb:line 19"

Answers (1)

Answers (1)

reiner_hille-doering
Active Contributor
0 Kudos

This is really easy:

Ge the WSDL from

http://<server-name>:8000/sap/bc/soap/wsdl11?services=BAPI_BUPA_ADDRESS_GETDETAIL&sap-client=<client...;

Use the WSDL to create a Web Reference (also called WS proxy).

Use is like


ICredentials cred = new NetworkCredential("<user>","<password>"); 
service.RfcService s = new service.RfcService(); s.Credentials = cred; 
result = s.BAPI_BUPA_ADDRESS_GETDETAIL(...);

Detailed information is available at http://service.sap.com/connectors -> Soap Processor -> Media Library