cancel
Showing results for 
Search instead for 
Did you mean: 

Visual .Net 2003 C# consumed WS from SAPNetweaver

Former Member
0 Kudos

Hello,

does anyone have experience with Visual .Net 2003 consuming a Web Service from SAP, e.g. a ABAP Function module exposed as WS and the WSDL which the WebService browser creates?

I used the C# example which comes from the SOAP Runtime and it does not work, e.g. the C# program gets only null values back. I used MS Infopath and that gets the value back from my web service but it cannot handle complex types, e.g. internal tables.

Stefan

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Alexander,

the support pack is SP 39 for WAS 620. I have not tested this as I had my solution working without the fix in SP 39.

Based on that I took the serialization out of the reference.cs the Visual Studio.Net creates from the WSDL you supoly.

Here is my piece of code:

namespace ZBxCreateOrder.WebAS {

using System.Diagnostics;

using System.Xml.Serialization;

using System;

using System.Web.Services.Protocols;

using System.ComponentModel;

using System.Web.Services;

/// <remarks/>

// [System.Diagnostics.DebuggerStepThroughAttribute()]

[System.ComponentModel.DesignerCategoryAttribute("code")]

[System.Web.Services.WebServiceBindingAttribute(Name="ZBxCreateOrderBinding", Namespace="urn:sap-com:document:sap:soap:functions:mc-style")]

[System.Xml.Serialization.XmlIncludeAttribute(typeof(Zbxorditem[]))]

public class ZBxCreateOrderService : System.Web.Services.Protocols.SoapHttpClientProtocol {

/// <remarks/>

public ZBxCreateOrderService() {

this.Url = "http://sapnts65.scottishcourage.com:8000/sap/bc/soap/zrfcbarbox";

}

/// <remarks/>

[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.sap.com/ZBxCreateOrder", RequestNamespace="urn:sap-com:document:sap:soap:functions:mc-style", ResponseElementName="ZBxCreateOrderResult", ResponseNamespace="urn:sap-com:document:sap:soap:functions:mc-style", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]

I hope it helps.

Stefan

[return: System.Xml.Serialization.XmlElementAttribute("Cwofactor")]

public string ZBxCreateOrder( string Customer, string Deldate, Zzbxemaildetails Emaildetails, ref Zbxorditem[] Items, string Ponumber, out string Orderno, out Bapireturn Wsreturn) {

object[] results = this.Invoke("ZBxCreateOrder", new object[] {

Customer,

Deldate,

Emaildetails,

Items,

Ponumber});

Items = ((Zbxorditem[])(results[1]));

Orderno = ((string)(results[2]));

Wsreturn = ((Bapireturn)(results[3]));

return ((string)(results[0]));

}

Former Member
0 Kudos

Hi Stefan,

great, it works for me as well (with an WAS 620, SP 34) by changing the serialization like you mentioned.

Many, many thanks,

Alexander

Former Member
0 Kudos

Great,

I found that through debugging and I got no reponse from SAP at all for 4 weeks. By the time they came back SP39 was not even released therefore I leave my code like it is and will not test this for a while with SP39.

Cheers

Stefan

Former Member
0 Kudos

Hi Alexiender,

I am trying to consume web service from my c# application bu am not able for that it's gives the error "Request failed with HTTP status 401:Unauthorized" i don't know why if u have a idea then plz or if u have a sample code, then provide me .I am very thankful for that .

I am using the visual studio 2005 and also not using the SAP.NET Connector.

thanx

regards

sandeep dabral

reiner_hille-doering
Active Contributor
0 Kudos

Hello Stefan,

calling RFC-function over Soap from C# should work fine. It's important to set the Creadentials property to a new NetworkCredentials object setting the correctl usrername and password.

If client is different than 0, it must be specified at the URL as "sap-client" query string parameter with three digits, e.g. "http://mysapserver:1080/sap/bc/soap/rfc?sap-client=001". You should also set PreAuthenticate to true.

Regards,

Reiner.

Former Member
0 Kudos

Hello Reiner,

it was a SAP bug and they are correcting it in a Support Pack. I got it to run after correcting the proxy class the .Net generates from the SAP WSDL by hand. It took me a while but I got it done.

Since the support pack is not yet available I will try the out of the box approach once again when we have implemented it.

Regards

Stefan

Former Member
0 Kudos

Hi Stefan,

please, could you specify the modifications you performed on the proxy class which was generated by VS from the SAP WSDL?

Do you know more about the Support Pack?

Thanks and Regards,

Alexander