locked
"A Connection attempt Failed.." Error during at Soap Request in Asp.net RRS feed

  • Question

  • I have connected a Third Party Web service with my web application, it is working fine
    in localhost. But after i uploaded the project in server it is showing the following error.

    A connection attempt failed because the connected party did not properly respond after a   period of time, or established connection failed because connected host has failed to respond 100.100.100.100:9090


    Here is my Soap Request:

    StringBuilder soapmsg = new StringBuilder();
            soapmsg.Append("<?xml version='1.0' encoding='UTF-8'?>");
            soapmsg.Append("<soap:Envelope xmlns='http://www.opentravel.org/OTA/2003/05'   xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:wsse='http://schemas.xmlsoap.org/ws/2002/12/secext'>");
            soapmsg.Append("<soap:Body><OTA_AirLowFareSearchRQ EchoToken='' SequenceNmbr='0' TransactionIdentifier='0' Version='1.001' xmlns='http://www.opentravel.org/OTA/2003/05' DirectFlightsOnly='false'>");
            soapmsg.Append("<POS xmlns='http://www.opentravel.org/OTA/2003/05'><Source AgentSine='' PseudoCityCode='NPCK' TerminalID='1'><RequestorID ID='AFFILIATE'/></Source><YatraRequests><YatraRequest AffiliateID='YTFABTRAVEL' MidOfficeAgentID='' AgentEmailID='' Destination='' AgentTypeCode='' Description='' DoNotCache='false' DoNotHitCache='true' IsYatraAgent='' LastResultFromCache='true' RequestType='"+di+"' YatraRequestTypeCode='SMPA'/></YatraRequests></POS>");
            soapmsg.Append("<OriginDestinationInformation>");
            soapmsg.Append("<DepartureDateTime WindowAfter='" + flexi + "' WindowBefore='" + flexi + "'>" + date + "</DepartureDateTime>");
            soapmsg.Append("<OriginLocation CodeContext='IATA' LocationCode='" + origin + "'>'" + origin + "'</OriginLocation>");
            soapmsg.Append("<DestinationLocation CodeContext='IATA' LocationCode='" + destination + "'>'" + destination + "'</DestinationLocation>");
            soapmsg.Append("</OriginDestinationInformation>");
            soapmsg.Append("</OTA_AirLowFareSearchRQ></soap:Body></soap:Envelope>");
    
            HttpWebRequest request = (HttpWebRequest)WebRequest.CreateDefault(new Uri(@"http://100.100.100.100:9090/services/spm/spm"));
            request.ContentType = "text/xml; charset=utf-8";
            request.Method = "POST";
            request.Accept = "text/xml";
            request.Headers.Add("SOAPAction", @"http://100.100.100.100:9090/services/spm/spm");
            StreamWriter writer = new StreamWriter(request.GetRequestStream(), Encoding.UTF8);
            writer.Write(soapmsg);
            writer.Flush();
            writer.Close();
    
            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                XNamespace ns = "http://www.opentravel.org/OTA/2003/05";
                XDocument xd = XDocument.Load(response.GetResponseStream());
             }        

     The following exception i got after i tried to connect the web service:

    SocketException (0x274c): A connection attempt failed because the connected party     did not properly respond after a period of time, or established connection failed because connected host has failed to respond 100.100.100.100:9090]
        System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddresssocketAddress) +251System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4,  Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout,   Exception& exception) +279

    have searched a lot. I am new to web service.
    Please let me know if you need more information.
     Thanks in advance,

    Wednesday, November 7, 2012 5:17 AM

All replies

  • First of all, why  in the world would you create the XML by hand instead of adding a Service Reference? See if you don't know how to do that.

    Second of all, that message simply indicates a timeout. It's possible that you have a firewall or some other hardware or software that is  blocking access to the remote server, or that you need to use a proxy on your server and don't need to use one on localhost.



    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects

    Friday, November 9, 2012 3:18 AM
    Moderator
  • Hi,

    Thanks for your replay.

    Actually, the Third Party Service is located in a URI. So i had to choose that way.

    I tried with service reference then found a method axis, but i really could not do with that method.

    The third party service provider sent a sample Request xml and i used in that same way and getting access with the service.

    Is any other way to access URI in Service Reference ?

    And finally, the problem has solved, because the the service  provider did not give Permission to our Host Server. Now everything is fine now. :-)

    Thanks again.

    Friday, November 9, 2012 6:49 AM
  • What do you mean, "located at a URI"? Usually, when you use "Add Service Reference", you specify the URL to the service (or rather, the URL to the service metadata or WSDL).

    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects

    Monday, November 12, 2012 7:09 PM
    Moderator