我正在嘗試使用SAP Web服務將PDA連接到SAP。SAP Webservice - 無法建立連接到C#中的網絡
我的視覺工作室版本是Visual Studio 2008專業版。 我跟着這個偉大的教程Create/Consume SAP Web service using SOAP Manager
我已經在我的C#項目中添加了Web服務,請找到下面的代碼。
SAP_WSDL.z_web_service_name service = new PDA_APP.SAP_WSDL.z_web_service_name();
SAP_WSDL.ZmmBatchPutawayFromPhp data = new PDA_APP.SAP_WSDL.ZmmBatchPutawayFromPhp();
data.PBktxt = "Test";
NetworkCredential cred = new NetworkCredential();
cred.UserName = "XXXXX";
cred.Password = "******";
service.Credentials = cred;
service.Proxy = new WebProxy("IP" , 1);
SAP_WSDL.ZmmBatchPutawayFromPhpResponse response = new PDA_APP.SAP_WSDL.ZmmBatchPutawayFromPhpResponse();
response = service.ZmmBatchPutawayFromPhp(data);
部署後我收到異常(WebException是未處理的),因爲無法建立連接到網絡。
System.Net.WebException - {"Could not establish connection to network."}
堆棧跟蹤:
" at System.Net.HttpWebRequest.finishGetResponse()\r\n at System.Net.HttpWebRequest.GetResponse()\r\n at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)\r\n at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)\r\n at System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke(String methodName, Object[] parameters, WebClientAsyncResult asyncResult)\r\n at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)\r\n at PDA_APP.SAP_WSDL.z_web_service_name.ZmmBatchPutawayFromPhp(ZmmBatchPutawayFromPhp ZmmBatchPutawayFromPhp1)\r\n at PDA_APP.login.button2_Click(Object sender, EventArgs e)\r\n at System.Windows.Forms.Control.OnClick(EventArgs e)\r\n at System.Windows.Forms.Button.OnClick(EventArgs e)\r\n at System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)\r\n at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)\r\n at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)\r\n at System.Windows.Forms.Application.Run(Form fm)\r\n at PDA_APP.Program.Main()\r\n"
狀態:System.Net.WebExceptionStatus.ConnectFailure
請幫我解決這個問題。
什麼錯誤?請用完整的堆棧跟蹤來複制和粘貼異常。 –
@FabrizioAccatino錯誤信息更新,請幫我解決這個問題。 –
我不確定,但在您的webservice運行的會話中?作爲會話0中的SYSTEM還是作爲會話1中的用戶?我對Webservices不熟悉,但如果它們的行爲與WindowsServices類似,則需要模擬成爲用戶才能訪問網絡。 https://stackoverflow.com/questions/46112248/how-to-pass-webcredentials-from-active-user-to-windows-service/46155993#46155993 – Jack