Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Consuming Web Service in C# application (SAP)


I want to consume a Web Service in my C# application. I am using below code however it throws an error: underlying connection established was closed. unexpected format was send".

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


1 Answer
SAP Expert

This error occurs when remote server doesn’t provide a response to your request and connection is broken before request is complete. To fix this issue, first setup a request that includes QaaWsHeader and ReportBlock configuration, then create the Request and in last using ServicesSoapClient, you can make method to send results.

Check out the below code and it may help:

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;

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.