简体   繁体   English

如何在 C# 中使用 SAP Web 服务

[英]How to Consume SAP Web Service in C#

I want to consume SAP web service into my c# application.我想在我的 c# 应用程序中使用 SAP Web 服务。 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...请帮我...

I'm actually using a soap service for a SAP WebService and I think I know what the problem is.我实际上正在为 SAP WebService 使用肥皂服务,我想我知道问题是什么。 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.您必须首先执行包含 QaaWsHeader 和 ReportBlock 配置的请求,然后创建请求,最后在 ServicesSoapClient 的帮助下创建发送结果的方法。

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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM