I am using the System.Net.HttpWebRequest object to POST data to an HTTPS web
page.
Other than prefixing the URL with "HTTPS://", do I need to do anything in my
code to indicate that this is SSL?
Here is my code:
// Create Web Request
string url = "https://something.net/something.dll";
HttpWebRequest oHttp =
(HttpWebRequest) WebRequest.Create(url);
// Post form variables
string params = "x_Version=" + version
+ "&x_DelimData=" + delimData
+ "&x_Login=" + login
+ "&x_Password=" + password
+ "&x_Amount=" + amount
+ "&x_Card_Num=" + cardNumber
+ "&x_Exp_Date=" + expirationDate
+ "&x_Type=" + type;
oHttp.Method="POST";
byte [] postBuffer =
System.Text.Encoding.GetEncoding(1252).GetBytes(pa rams);
oHttp.ContentLength = postBuffer.Length;
Stream postData = oHttp.GetRequestStream();
postData.Write(postBuffer,0,postBuffer.Length);
postData.Close();
// Get results
HttpWebResponse myResponse = (HttpWebResponse) oHttp.GetResponse();
Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader loResponseStream =
new StreamReader(myResponse.GetResponseStream(), enc);
string retHtml = loResponseStream.ReadToEnd();
myResponse.Close();
loResponseStream.Close();
messages = retHtml;"dgiard" spoke:
> I am using the System.Net.HttpWebRequest object to POST data to an
> HTTPS web page.
> Other than prefixing the URL with "HTTPS://", do I need to do
> anything in my code to indicate that this is SSL?
Check out if the framework's default certificate policy (URL below)
works for you. If not, you need to implement your own. But that should
be it.
http://msdn.microsoft.com/library/d...rl=/library/en-
us/cpref/html/frlrfSystemNetServicePointManagerClassCertificateP olicyTop
ic.asp
Cheers,
--
Joerg Jooss
joerg.jooss@.gmx.net
Thanks, Joerg.
"Joerg Jooss" <joerg.jooss@.gmx.net> wrote in message
news:OfG1RIqTDHA.3132@.tk2msftngp13.phx.gbl...
> "dgiard" spoke:
> > I am using the System.Net.HttpWebRequest object to POST data to an
> > HTTPS web page.
> > Other than prefixing the URL with "HTTPS://", do I need to do
> > anything in my code to indicate that this is SSL?
> Check out if the framework's default certificate policy (URL below)
> works for you. If not, you need to implement your own. But that should
> be it.
> http://msdn.microsoft.com/library/d...rl=/library/en-
> us/cpref/html/frlrfSystemNetServicePointManagerClassCertificateP olicyTop
> ic.asp
> Cheers,
> --
> Joerg Jooss
> joerg.jooss@.gmx.net
Showing posts with label webpage. Show all posts
Showing posts with label webpage. Show all posts
Monday, March 26, 2012
Saturday, March 24, 2012
System.Net.Sockets.SocketException+webservice+Sourabh Das
Hi,
I have placed a webservice in the webserver. When I access it from a webpage, default.aspx on a click of a button i get the following error:
No connection could be made because the target machine actively refused it
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it
Source Error:
Line 91: [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/getProducts", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
Line 92: public System.Data.DataSet getProducts(int productid) {
Line 93: object[] results = this.Invoke("getProducts", new object[] {
Line 94: productid});
Line 95: return ((System.Data.DataSet)(results[0]));
Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\6dcecb27\a382a372\App_WebReferences.lgdo8f58.0.cs Line: 93
Stack Trace:
[SocketException (0x274d): No connection could be made because the target machine actively refused it]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +1002082
System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +33
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +431
[WebException: Unable to connect to the remote server]
System.Net.HttpWebRequest.GetRequestStream() +1504461
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +103
localhost.ProductsService.getProducts(Int32 productid) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\6dcecb27\a382a372\App_WebReferences.lgdo8f58.0.cs:93
_Default.btnCategory_Click(Object sender, EventArgs e) in D:\users\Padmajamvl\arete\www\Default.aspx.vb:40
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
Please tell me what is the error. Its urgent.
Regards."Unable to connect to the remote server"
This means, you must update the web reference to access the web service (Rebuild the WSDL file automatically)
Or the server doesn't allow access to the web service folder (not marked as a web application on IIS)
I have placed a webservice in the webserver. When I access it from a webpage, default.aspx on a click of a button i get the following error:
No connection could be made because the target machine actively refused it
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it
Source Error:
Line 91: [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/getProducts", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
Line 92: public System.Data.DataSet getProducts(int productid) {
Line 93: object[] results = this.Invoke("getProducts", new object[] {
Line 94: productid});
Line 95: return ((System.Data.DataSet)(results[0]));
Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\6dcecb27\a382a372\App_WebReferences.lgdo8f58.0.cs Line: 93
Stack Trace:
[SocketException (0x274d): No connection could be made because the target machine actively refused it]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +1002082
System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +33
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +431
[WebException: Unable to connect to the remote server]
System.Net.HttpWebRequest.GetRequestStream() +1504461
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +103
localhost.ProductsService.getProducts(Int32 productid) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\6dcecb27\a382a372\App_WebReferences.lgdo8f58.0.cs:93
_Default.btnCategory_Click(Object sender, EventArgs e) in D:\users\Padmajamvl\arete\www\Default.aspx.vb:40
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
Please tell me what is the error. Its urgent.
Regards."Unable to connect to the remote server"
This means, you must update the web reference to access the web service (Rebuild the WSDL file automatically)
Or the server doesn't allow access to the web service folder (not marked as a web application on IIS)
Subscribe to:
Posts (Atom)