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

时间:2014-06-30 13:14:35

标签: c# asp.net web-services sap abap

我想将SAP Web服务用于我的c#应用程序。为此我写下了一段代码。

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);

但是在最后一行我得到了#34;基础连接已经关闭。意外的格式发送"错误。

请帮帮我......

1 个答案:

答案 0 :(得分:1)

我实际上正在为SAP WebService使用soap服务,我想我知道问题所在。您必须首先执行包含QaaWsHeader和ReportBlock配置的请求,然后创建请求,最后在ServicesSoapClient的帮助下生成发送结果的方法。

以此为例,我希望这会有所帮助,祝你好运

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;