Hi All,
I need to extract the data from a WebService and then load the same into SQL Database.
I have the following with me.
a WSDL File, a XSD file, A certificate, username and password and the xml used to connect to the service.
Below mentioned is the code to connect to service
<SOAP-ENV:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" SOAP-ENV:mustUnderstand="0"><wsse:UsernameToken><wsse:Username>[USERID]</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">[PASSWORD]</wsse:Password></wsse:UsernameToken></wsse:Security></SOAP-ENV:Header>
HttpWebRequest myXmlhttp = (HttpWebRequest)WebRequest.Create(myURL); myXmlhttp.Proxy = new WebProxy() { UseDefaultCredentials = true }; myXmlhttp.Method = "POST"; myXmlhttp.Headers.Add("SOAPAction", "urn:retrieveCoverDecision"); myXmlhttp.ContentType = "text/xml;charset=UTF-8"; byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes(myXMlMessage); myXmlhttp.ContentLength = requestBytes.Length; Stream requestStream = myXmlhttp.GetRequestStream(); requestStream.Write(requestBytes, 0, requestBytes.Length); requestStream.Close(); HttpWebResponse res = (HttpWebResponse)myXmlhttp.GetResponse(); StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.Default); string backstr = sr.ReadToEnd(); sr.Close(); res.Close();
When my Code reaches
Stream requestStream = myXmlhttp.GetRequestStream();
Its throwing the below exception.
.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: 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 217.33.210.17:443
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
When I hit the URL its opening in Internet Explorer.
I don't know what wrong I am doing, how to use WSDL File or XSD file or a reference to it or how to use certificate if I have to use any. :(
Please help
Thanks & Regards,
Manjunath C Bhat,
http://manjunathcbhat.blogspot.com
http://manjunathcbhat.wordpress.com