我正在尝试使用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