How to Consume SAP Web Service in C#

元气小坏坏 提交于 2019-12-24 05:51:38

问题


I want to consume SAP web service into my c# application. For that i wrote one block of code given below.

NetworkCredential ntobj = new NetworkCredential();
            ZWEBSERVICE_INTERNAL_ORDER2 zClassobj = new ZWEBSERVICE_INTERNAL_ORDER2();
            ZbapiFiCreateInternalOrder zMethodObj = new ZbapiFiCreateInternalOrder();
            ZbapiFiCreateInternalOrderResponse zMethodResobj = new ZbapiFiCreateInternalOrderResponse();

            ntobj.UserName = "alpldev";
            ntobj.Password = "alpl123";

            zClassobj.PreAuthenticate = true;
            zClassobj.Credentials = ntobj;

            zMethodObj.IDriverNo = "KD00000014";
            zMethodObj.IPlant = "1001";
            zMethodObj.ITripNo = "1001201406140027";
            zMethodObj.IVhclNo = "AP29Q8639";

            zMethodResobj = zClassobj.ZbapiFiCreateInternalOrder(zMethodObj);

but at last line i got "underlying connection established was closed. unexpected format was send" error.

please help me...


回答1:


I'm actually using a soap service for a SAP WebService and I think I know what the problem is. You have to do first a Request including the QaaWsHeader and the ReportBlock configuration, then create the Request and finally with help with the ServicesSoapClient make the method to send your result.

Use this as an example, I hope this will help, good luck

Sellers.QaaWSHeader qaawsHeaderDatos = new Sellers.QaaWSHeader();
Sellers.GetReportBlock_WBS_Sellers getReportBlock = new Sellers.GetReportBlock_WBS_Sellers();
getReportBlock.login = userWS;
getReportBlock.password = passWS;
getReportBlock.refresh = true;
getReportBlock.startRow = 0;
getReportBlock.startRowSpecified = true;
getReportBlock.endRow = 1000;
getReportBlock.endRowSpecified = true;
Sellers.GetReportBlock_WBS_Sellers_Request WSRequest = new Sellers.GetReportBlock_WBS_Sellers_Request(qaawsHeaderDatos, getReportBlock);

Sellers.BIServicesSoap BiService = new Sellers.BIServicesSoapClient();
Sellers.GetReportBlock_WBS_Sellers_Response FinalResponse = BiService.GetReportBlock_WBS_Sellers(WSRequest);
object[][] yourTable = FinalResponse.table;


来源:https://stackoverflow.com/questions/24490998/how-to-consume-sap-web-service-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!