Webservice created in SAP - Could not establish connection to network in C#

1.2k views Asked by At

I am trying to connect PDA to SAP using SAP Web Service.

EDIT (from OP answer):

"I created [the Web Service] in soamanager in SAP"

My visual studio version is Visual Studio 2008 Professional Edition. I followed this great tutorial: Create/Consume SAP Web service using SOAP Manager.

I have added web service in my C# project, please find the below code.

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

After deploying I am getting exception(WebException was unhandled) as could not establish connection to network.

System.Net.WebException - {"Could not establish connection to network."}

Stack Trace:

at System.Net.HttpWebRequest.finishGetResponse()
at System.Net.HttpWebRequest.GetResponse()
at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.doInvoke(String methodName, Object[] parameters, WebClientAsyncResult asyncResult)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at PDA_APP.SAP_WSDL.z_web_service_name.ZmmBatchPutawayFromPhp(ZmmBatchPutawayFromPhp ZmmBatchPutawayFromPhp1)
at PDA_APP.login.button2_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.ButtonBase.WnProc(WM wm, Int32 wParam, Int32 lParam)
at System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam)
at Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain)
at System.Windows.Forms.Application.Run(Form fm)
at PDA_APP.Program.Main()

Status : System.Net.WebExceptionStatus.ConnectFailure

Please help me out to solve this problem.

2

There are 2 answers

1
Namphibian On

Looks like some networking issues from your client to the SAP SOAP server. Here is some tips and tricks to check connectivity between the client and server.

  1. Use Ping And Tracert: The utilities can be used to check if the client can see the server. First try ping which is just a basic check if the server available on the client network. Keep in mind that some network restrict use of ping. Secondly try tracert(Trace Route). This utility will show you a list of IP that the client has to travel to to get the server.

  2. If both the steps above work and you can confirm that the server is reachable on the network then you can try to do a telnet sessions from the client to the server on the port where the service lives. If you can connect then you DON'T have a network issue if you cannot connect you probably have a firewall issue between your client and server.

In Summary:

Try to ping it. If this is successful then telnet to it. If you cannot ping try a tracert to the server if this is successful then telnet to it.

0
Archana Palani On

I have solved this by myself , i have activated Web service which i created in soamanager in SAP using SICF T.Code it solved my issue. thanks all for the effort.